Category Archives: Wordpress

Tikiwiki Migration to WordPress Notes – Part 3

After migrating from TikiWiki, you will probably want to rewrite any old links to the new pages. In my case, all of my articles had a url ending articleXXX.html. If you have any links in the database that were using these names, you can find them with this:

grep -o “….article[0-9]….” dump.sql

Where dump.sql is a MySQL dump of your WordPress database. You can then update any articles using the WordPress editor accordingly.

To catch external sites that may have references articleXXX.html or (in Tiki’s default formats of tiki-read_article.php?articleId=XXXX or tiki-print_article\.php?articleId=XXX) then the following apache rules should do the job:

rewritecond %{HTTP_HOST} ^www\.richii\.com(:80)?$ [NC]
rewritecond %{REQUEST_URI} ^/tiki-read_article\.php$ [OR]
rewritecond %{REQUEST_URI} ^/tiki-print_article\.php$
rewritecond %{QUERY_STRING} articleId\=([0-9]+)
RewriteRule ^(.*)$ [R]

RewriteRule ^/article([0-9]+)([A-Za-z.]+)$ /?p=$1 [R=301,L]
RewriteRule ^/article([0-9]+)$ /?p=$1 [R=301,L]

That should send people from articleXXX.html to /?p=XXX. Then, if WordPress is using SEO-friendly URL’s, it will then send folks to /seo-friendly-article-name

Whilst of the subject of links, it’s worth checking that all of your outbound links are good. A good module that can do this is Broken Link Checker. To set this up, first activate Broken Link Checker in modules. Then go to configure and select:

Which Links to Check: Add:
Embedded YouTube videos
Embedded YouTube videos (old embed code)
Embedded DailyMotion videos

Protocols and API’s:
YouTube API

Check the plugin website for more documentation of this plugin.

One nice WordPress Plugin is WPTouch. I’m not sure if there’s a similar feature in Tikiwiki, but this plugin converts a WordPress site into an application-like theme, complete with ajax loading articles and effects when viewed from the mobile devices like the iPhone, iPod touch, Android mobile devices, Palm Pre/Pixi and BlackBerry OS6 mobile devices.

The install is fairly simple, just search for WPTouch in the Plugins section and download and activate it.

To configure it, just go to Settings -> WPtouch

One option you may wish to disable:
Enable Email Menu Item (Uses default WordPress admin e-mail)

Finally, you will probably want a Contact Form of some sort. One that comes highly recommended in many guides is Fast Secure Contact Form. Install through the Plugins Menu and you’ll then the options under Plugins -> Fast Secure Contact Form Options. You can probably accept the defaults, but perhaps disable “Accept Meeting Requests via vCita”

Tikiwiki Migration to WordPress Notes – Part 2

This article follows up on Tikiwiki Migration to WordPress Notes – Part 1. You’ve now got a working WordPress site with your old TikiWiki articles in it. However, there’s some further imports we can do to use some of the Tiki features such as topic images.

One nice feature in Tikiwiki is that each article/topic was assigned an icon. To get these icons into WordPress, there are a couple of steps.

First, you’ll want to upload your topic images from Tikiwki into WordPress. The easiest way to do this is to install the plugin Add From Server. Once installed, check the settings under Settings -> Add From Server.

Under User access Control select:
Any users with the ability to upload files listed below : admin

Copy over images from Tikiwiki (probably in images/topics) to /path/to/website/wp-content/

Then click on media -> Add From Server

The images should all get uploaded and appear somewhere like /path/to/website/wp-content/uploads/2003/11/stuff.gif

The next step is associate each icon with a category. This is done in the WordPress database.

I should stress at this point that the following steps are at your own risk and are unsupported. Although this worked for WordPress 3.3.1 in my environment, there’s no guarantee that this will work for you. And ALWAYS back up your database prior to performing any database changes.

Here’s the basic process.

The uploaded files now appear in the wp_postmeta table. Let’s say I want to associate all the ‘dotdance’ topics with my dotDance icon.

Step1: Identify the post_id for the image you want to use:

mysql> select * from wp_postmeta where meta_key=’_wp_attached_file’;
| meta_id | post_id | meta_key | meta_value |
| 716 | 325 | _wp_attached_file | 2003/11/dot_dance.gif |

Make a note of the post_id associated with the image.

Step 2: Next we look in wp_terms to find the dotDance category:
mysql> select * from wp_terms;
| term_id | name | slug | term_group |
| 9 | dotDance | dotdance | 0 |

Step 3: We need to match this term_id with the term_id in the wp_term_taxonomy table:

mysql> select * from wp_term_taxonomy where term_id=’9′ and taxonomy=’post_tag’;
| term_taxonomy_id | term_id | taxonomy | description | parent | count |
| 16 | 9 | post_tag | | 0 | 49 |
1 row in set (1.91 sec)

Step 4: We now need to find all posts with this term_taxonomy_id=16 (dotDance) category:

mysql> select * from wp_term_relationships where term_taxonomy_id = 16;
| object_id | term_taxonomy_id | term_order |
| 26 | 16 | 0 |
| 56 | 16 | 0 |
| 57 | 16 | 0 |
| 63 | 16 | 0 |

So we know post’s 26, 56, 57 and 63 are all in the (dotDance) category.

Step 5: To make these posts use our image (image id 325 found in step 1) we can simply insert entries into wp_postmeta as follows:

insert into wp_postmeta (post_id,meta_key, meta_value) values (’26’,’_thumbnail_id’,’325′)
insert into wp_postmeta (post_id,meta_key, meta_value) values (’56’,’_thumbnail_id’,’325′)
insert into wp_postmeta (post_id,meta_key, meta_value) values (’57’,’_thumbnail_id’,’325′)
insert into wp_postmeta (post_id,meta_key, meta_value) values (’63’,’_thumbnail_id’,’325′)

This can be a bit time consuming if you’ve got a lot of categories to import.

To automate the process, we can script this up.

First, create a csv file with two entries per category. The first entry should be the image id (found from ‘select post_id from wp_postmeta where meta_key=’_wp_attached_file’;) and the second should be the term id (found from ‘select term_id, name from wp_terms;’)

For the exmaple of the dotDance Category shown above this would be:

Once you’ve got your CSV file, you can upload the data into wp_postmeta by running this script:

cat $1 | while read line
val1=`echo $line|cut -f1 -d,`
val2=`echo $line|cut -f2 -d,`
echo “insert into wp_postmeta (post_id,meta_key, meta_value) select wp_term_relationships.object_id, ‘_thumbnail_id’,’${val1}’ from wp_term_relationships,wp_term_taxonomy where term_id=${val2} and taxonomy=’post_tag’ and wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id;” >> /tmp/script$$
echo “SQL has been generated in /tmp/script$$”
echo “”
echo “Here are the contents of /tmp/script$$”
echo “”
cat /tmp/script$$
echo “Now run this sql as follows:”
echo “mysql -u –username=XXX –password=YYYY –database=ZZZZZ < /tmp/script$$”

Be sure to take a backup of your database before running the script. Here’s how you can confirm it’s worked: Before associating the featured images to the WordPress posts: mysql> select * from wp_postmeta where meta_value=’325′;
Empty set (0.01 sec)

After associating the featured images to the WordPress posts:
mysql> select * from wp_postmeta where meta_value=’325′;
| meta_id | post_id | meta_key | meta_value |
| 789 | 26 | _thumbnail_id | 325 |
| 790 | 56 | _thumbnail_id | 325 |

If needed, you can remove the topic associations:

mysql> delete from wp_postmeta where meta_value=’325′ and meta_key=’_thumbnail_id’;

To confirm that all is working as expected, just login to WordPress, select an article that’s been assigned to a category and look to see if “Featured Image” has been set. If you are using a theme that displays category images for articles, then it should be displaying these on either the article homepage or the article itself .

Tikiwiki Migration to WordPress Notes – Part 1

A short article on how to perform a Tikiwiki migration to WordPress.

I’ve been using Tiki Wiki CMS for quite some time. The software was up to it’s job and added loads and loads of features for a fully-qualified CMS for which you need lots of permission settings, features like blogs, galleries, forums and link directories, etc. I’d always made lots of customisations to my Tiki install, so upgrades were always a bit of a pain. I recently discovered a WordPress For Beginners Magazine which showed that WordPress offered lots of great functionality with lots of active development. It offered a lean base from which you can add modules which are relevant to your site.

Here’s a brief set of steps in performing a TikiWiki migration over to WordPress 3.3.1:

  1. Dump out your TikiWiki database articles into a CSV file and save it to the desktop (script to follow)
  2. Create the MySQL database and user which you’ll use for WordPress:
    create database wordpressdbname;
    GRANT ALL PRIVILEGES ON wordpressdbname.* to wordpressuser@localhost
    identified by ‘some_password’ with GRANT OPTION;
  3. Unpack WordPress into a clean directory and perform a normal install
  4. Go to the Plugins section and install and activate the following plug-ins:
    WordPress SEO by Yoast
    CSV importer
    Advanced Excerpt
    Google Analytics for WordPress by Yoast
  5. Using the CSV importer module, upload your CSV file containing all of your articles. If successful, you will get something like this: “Imported 269 posts and 0 comments in 35.36 seconds” If not, check your CSV file to make sure all the quotation marks are appropriately escaped
  6. Set your site title and tag lines under Settings. Also set your preferred date format.
  7. If you don’t want to enable comments, click on Settings -> Discussion:
    Uncheck: Allow people to post comments on new articles
    Check: Users must be registered and logged in to comment
  8. Follow the setup for Google Analytics and WordPress SEO.
  9. Chose a theme like Reflex Plus. In order to use this WordPress theme all you have to do is, upload the Reflex Plus Theme package through (WordPress Dashboard -> Appearance -> Themes -> Upload) and Activate it like you do for any other WordPress theme.
  10. Optionally, edit the Reflex Plus theme’s header.php as follows
    Add the following lines:
    <meta name=”robots” content=”INDEX, FOLLOW, NOCACHE, NOARCHIVE” />
    <meta name=”revisit-after” content=”1 days” />Change the following lines:
    <title><?php bloginfo(‘name’); wp_title();?></title>
    <title><?php wp_title(”); ?></title>
  11. Copy over favicon.ico from your old Tikiwiki directory to the new one
  12. One nice feature about WordPress SEO by Yoast is that you can perform online SEO Page Analysis before you submit the post.  This requires PHP’s Document Object Model.  If you don’t have this installed, you will get the error “Error: your hosting environment does not support PHP’s Document Object Model. To enjoy all the benefits of the page analysis feature, you’ll need to (get your host to) install it.”   Check your PHP installation to see if DOM/XML is enabled.  On Red Hat Enterprise Linux if you are using the IUS Community repository and LAMP stack, you can just perform a simple “yum install php53u-xml”

That all for now – more to follow later.