Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've been reading a bunch of posts about this with no luck so far. I can't seem to figure out what is the problem.

I have the following:

Custom Post Type: Sermons

Custom Taxonomy: Series

My urls right now look like this mysite.com/Sermons/ParentTerm/ChildTerm/Post

When viewing the Parent Term of the series taxonomy the first page works fine. However when navigating to the next page using wordpress' pagination it throws a 404. So trying to view mysite.com/Sermons/ParentTerm/page/2/ does not work.

I'm guessing I need to do a URL rewrite? I tried the following with no luck:

function sermon_rewrite_rules() {
  add_rewrite_rule('sermons/%series%/([^/]+)/?$',
  'index.php?post_type=sermons&%series%=$matches[1]', 'top');
  add_rewrite_rule('sermons/%series%/([^/]+)/page/([0-9]+)?$',
  'index.php?post_type=players&type=$matches[1]&paged=$matches[2]','top');
}
add_filter('init', 'sermon_rewrite_rules');

I've tried reading up on everything I can about this and it's all starting to blur together, any help would be greatly appreciated. Thanks.

EDIT

So after some tinkering around I have this working and allowing for paginaiton on taxonomy pages, but it's breaking my actual post now and displaying the terms there. I feel like I'm super close to the answer, any ideas?

function sermon_rewrite_rules() {
 add_rewrite_rule( 
    '^sermons/([^/]*)/([^/]*)/(\d*)?',
    'index.php?series=$matches[1]&p=$matches[2]&paged=$matches[3]',
    'top' 
 );
}
add_filter('init', 'sermon_rewrite_rules');
share|improve this question

2 Answers 2

Ftntravis's answer is helpful but it is important to note that the regular expression has 2 matching groups in parentheses and the query it redirects to tries to reference 3 groups.

Other notes:

The p parameter in the query refers to the post ID to query.

share|improve this answer
1  
This isn't really an independent answer. It should instead have been a comment on FTNtravis's answer. I don't think you have enough rep to comment, though. Until you do have the rep, please refrain from posting comments in the answer box. –  s_ha_dum Feb 1 '13 at 16:53

Alright, so after lots of reading, copying & pasting, and plugin installation I have finally gotten it to work.

This is using a custom post type: Sermons, a custom taxonomy: Series and allowing pagination on both pages.

First I downloaded this plugin here: http://wordpress.org/extend/plugins/monkeyman-rewrite-analyzer/

Next I typed in the URL I wanted to change to get what I needed to rewrite, then ended up with the following working code:

function sermon_rewrite_rules() {
  add_rewrite_rule(
    'sermons/(.+?)/page/?([0-9]{1,})/?$', //THIS IS WHERE I PASTED INFO FROM PLUGIN
    'index.php?series=$matches[1]&p=$matches[2]&paged=$matches[3]',
    'top'
  );
}
add_filter('init', 'sermon_rewrite_rules');

Hope this can help someone else.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.