WP Compatibility

jerome, Tuesday 10 May 2005 22:40:21 PST

LightPress has been designed from the ground up as a full replacement for the WordPress front-end. This includes a permalink and

.htaccess

system for "pretty" URLs. The only interaction with WordPress is through the database. This means that LightPress is fully compatible with WordPress 1.5, including the new 1.5.1 release.

Now this is fine if you're starting a site from scratch, but if you're converting an existing WordPress site you may not want to mess with your permalinks. I've made the conversion and hopefully I've done most of the hard work for you! The 1.0.2 LightPress release includes a file called

wp-compat.php

which converts WordPress-style queries into a format that LightPress prefers. So without further ado, here's what you need to look at.

  1. Don't overwrite your WordPress

    .htaccess

    file with the version included with LightPress!

  2. Edit your LightPress

    index.php

    and insert the following line at the beginning of the file:

    include_once('wp-compat.php');
  3. If you're using one of the supplied LightPress templates, you may want to add the following lines to your WordPress

    .htaccess

    file below the line reading

    #END WordPress

    :

    RewriteRule ^rss2.xml feed.php [L]
    RewriteRule ^rss.xml feed.php [L]
    RewriteRule ^atom.xml feed.php?feed=atom [L]
  4. Make sure you setup your permalink settings correctly in

    config.php

    . The important settings are:

    • post_prefix

      – permalink for each post

    • category_prefix

      – permalink for viewing categories

    • archives_prefix

      – permalink for dated archive

    • static_prefix

      – permalink for pages

    • search_prefix

      – permalink for searches

    • author_prefix

      – permalink for viewing posts by a particular author

    You'll want to edit

    post_prefix

    to match what you've set for your WordPress permalink option. The conversion is pretty simple, for example vapourtrails.ca uses:

    • WordPress:

      /%year%-%month%/%postname%/
    • LightPress:

      'post_prefix' = '%Y-%m'

    In the above

    %Y

    is replaced by the 4-digit year and

    %m

    is replaced by the 2-digit month. The actual post name is handled by using the template tag

    {post_permalink}

    in your templates.

    You should also set

    archives_prefix

    and

    static_prefix

    to match any leading text in your permalink structure (blank in my case, but some people use

    archives

    , etc). Finally, set

    category_prefix

    to match your WordPress category permalink setting (the default is

    category

    )

  5. Edit your templates to use the new structure. In most cases you'll have to change very little, but one important spot is inside the Pagination templates:

    • Edit the file

      plugins/pagination_multi.xml

      (located in your active template directory)

    • Change the links to use

      /page/

      instead of

      /record/
    • Change the template tags

      {page_next}

      and

      {page_previous}

      to

      {paged_next}

      and

      {paged_previous}

      , respectively.

And that's it! Once setup, you can continue to let WordPress edit & update

.htaccess

and LightPress won't skip a beat.

Of course, it would be a lot easier to use the LightPress system...

Readers' Comments

  1. jerome

    Ludo, sorry fot the long post but the post.xml template in kubrick seems to be missing the {post_more} tag (should be right after {post_content})

  2. jerome

    Oh my, that was interesting…

  3. ludo

    wow :)

    switch to default?

  4. ludo

    Solved :) We just have to replace { with { and } with } before inserting the comment in the db.

  5. ludo

    Switched back to kubrick, guess we will have to release 1.0.3 tomorrow. Oh, and I guess we’ll better move the site away from sf, as I cannot get LP to send emails for comments from here…

  6. Ramin

    Wow.. you guys have been busy. Just wanted to let you know that I’ve officially made the switch and even put up a little review of LP on my blog. Great job and thanks again for all the help.

    Now I just gotta upgrade to the latest version. Hope nothing breaks! :-)

  7. jerome

    Yes, it’s been interesting to say the least… :)

    The upgrade should be easy if you haven’t done too much hacking. I’d suggest renaming your modified theme so you don’t accidentally overwrite it. The only other files to watch out for are config.php, .htaccess and index.php (only if you changed it).