Discussion:
Custom Post Type URL Rewrite
AJ Morris
2013-10-22 17:06:45 UTC
Permalink
Hey all,

I have a CPT that we use for press releases and I'd like the archive page to live under a page, eg. example.com/about-us/pressreleases.

The problem I'm encountering is that the menu is just wp_list_pages(). I thought I'd be able to do something with 'rewrite' => array( 'slug' => 'about-us/pressreleases', 'with_front' => true)) like I did for single press releases, but that doesn't seem to work. It seems the only way I could get this to work is to create a page, and assign it a special template in which I have a custom query on it.

Does that make sense? Is there a better way to go about it?

Thanks in advance!
--
AJ Morris
Eric Hendrix
2013-10-22 18:04:50 UTC
Permalink
I had to use the same setup for our Press Releases too. I don't know enough to figure out a better way around it. It works pretty cleanly though.




Eric

Eric A. Hendrix
308 McFadyen Drive
Fayetteville, NC
28314
910.644.8940
***@gmail.com
www.hendronix.com
Post by AJ Morris
Hey all,
I have a CPT that we use for press releases and I'd like the archive page to live under a page, eg. example.com/about-us/pressreleases.
The problem I'm encountering is that the menu is just wp_list_pages(). I thought I'd be able to do something with 'rewrite' => array( 'slug' => 'about-us/pressreleases', 'with_front' => true)) like I did for single press releases, but that doesn't seem to work. It seems the only way I could get this to work is to create a page, and assign it a special template in which I have a custom query on it.
Does that make sense? Is there a better way to go about it?
Thanks in advance!
--
AJ Morris
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Jeremy Clarke
2013-10-29 14:04:06 UTC
Permalink
Post by AJ Morris
It seems the only way I could get this to work is to create a page, and
assign it a special template in which I have a custom query on it.
Does that make sense? Is there a better way to go about it?
I've found that almost all instances where page templates seem needed can
be solved much more effectively with a custom shortcode:

http://codex.wordpress.org/Shortcode_API

Shortcodes are theme independent (put it in a tiny plugin with your other
related code) and you don't have to worry about duplicating templates.

Jeremy Clarke | jeremyclarke.org
--
Jeremy Clarke
Code and Design • globalvoicesonline.org
Loading...