[wp-hackers] Rewrite rule for pages from old site

Brenda Egeland brenda at redletterdesign.net
Fri Jun 22 13:03:59 UTC 2012


I am converting a non-WP site to WP. There are hundreds of files in the form:sermons/sermon20120325.php

These can be found on the new site at /sermon/2012/03/25?post_type=sermon 

Sermon is a custom post type. I've tried add this to my functions.php for a custom rewrite rule:

add_action('init', 'find_old_sermons');
function find_old_sermons() {
  add_rewrite_tag("%sermons%", '([^/]*)'); 
  add_rewrite_rule(
    '^/sermons/sermon([0-9]{4})([0-9]{2})([0-9]{2})\.php?',
    '$matches[1]/$matches[2]/$matches[3]?post_type=sermon',
    'top'
  );
}

But I keep getting a sorry...not found. I've tried resaving the permalinks in the Settings panel, and still no luck.

Thanks for your help.

Brenda Egeland
Red Letter Design
www.RedLetterDesign.net
301-260-7545





More information about the wp-hackers mailing list