[wp-hackers] Permalinks, Custom Post Types & Pagination

Olumide Alabi me at olumidealabi.com
Wed Oct 27 10:32:02 UTC 2010

Hi Guys,
Sadly, I haven't made any headway with this.

I took this from the Smarter Custom Post Types library

add_filter( 'generate_rewrite_rules', array($this, 'add_rewrite_rules') );

public function add_rewrite_rules( $wp_rewrite ) {
	$new_rules = array();
	$new_rules[$this->post_slug . '/page/?([0-9]{1,})/?$'] =
'index.php?post_type=' . $this->post_type . '&paged=' .
	$new_rules[$this->post_slug . '/(feed|rdf|rss|rss2|atom)/?$'] =
'index.php?post_type=' . $this->post_type . '&feed=' .
	$new_rules[$this->post_slug . '/?$'] = 'index.php?post_type=' .

	$wp_rewrite->rules = array_merge($new_rules, $wp_rewrite->rules);
	return $wp_rewrite;

and made it into this

add_filter( 'generate_rewrite_rules', 'add_rewrite_rules' );

function add_rewrite_rules( $wp_rewrite ) {
$new_rules = array();
 $new_rules['media/press-releases' . '/page/?([0-9]{1,})/?$'] =
'index.php?post_type=press_release&paged=' . $wp_rewrite->preg_index(1);
 $new_rules['media/press-releases' . '/(feed|rdf|rss|rss2|atom)/?$'] =
'index.php?post_type=press_release&feed=' . $wp_rewrite->preg_index(1);
 $wp_rewrite->rules = array_merge($new_rules, $wp_rewrite->rules);
return $wp_rewrite;

since I'm trying to fix just the Press Releases issue. I didn't use the
library itself as it would mean that I had to recreate all my custom post
types using the library. I just took this bit of code and put it in my
*functions.php* file.

The line that deals with feeds works, so I can reach the feeds by just
appending '/feed/' to the URL. The funny thing is that this was just icing
on the cake.

The other one that's supposed to handle pagination, which is the actual
problem I'm tryna fix,  just throws me to the Home Page.

Right now, I'm kinda lost.

Help! Please!!
Best Regards

Olumide Alabi
Mobile | +234 802 359 9606
CDMA | +234 702 838 6589
Chat [image: Google Talk:] luminusdadon [image: Skype:] luminusdadon
Contact Me [image: Linkedin] <http://www.linkedin.com/in/luminus>[image:
Facebook] <http://www.facebook.com/luminus>[image:
Twitter] <http://twitter.com/luminus>

More information about the wp-hackers mailing list