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

mccormicky mccormicky at gmail.com
Wed Oct 27 13:35:41 UTC 2010


I'm going to be attempting this soon which is why I saved this link.

http://boring-group.com/blog/2010/05/28/wordpress-query_posts-with-custom-post_types-and-paged-solved/




On Wed, Oct 27, 2010 at 6:32 AM, Olumide Alabi <me at olumidealabi.com> wrote:

> 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=' .
> $wp_rewrite->preg_index(1);
>        $new_rules[$this->post_slug . '/(feed|rdf|rss|rss2|atom)/?$'] =
> 'index.php?post_type=' . $this->post_type . '&feed=' .
> $wp_rewrite->preg_index(1);
>        $new_rules[$this->post_slug . '/?$'] = 'index.php?post_type=' .
> $this->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
> <http://www.holidaysandcash.com/luminus>
> 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:
> Tumblr]<http://luminus.tumblr.com>[image:
> Twitter] <http://twitter.com/luminus>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list