Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Custom post type with archive under parent page

Hi there,

I'm struggling with a problem on one of my websites. I'll try to explain what I want to achieve:

  • I need a custom post type called 'Press room', where posts will come about various things the company achieved.
  • I need the archive page of that custom post type to be the child page of the main about page, which is located under the normal pages.
  • I need pagination on the archive page of the custom post type.
  • I need to use the read more tag on the posts inside the custom post type.

I made the custom post type, added posts, made a child page of the about page and did a query for that custom post type. Now the problem is that I'm using a template for the archive page, and not the archive template itself, because the archive page is a child of about, which gives problems with the permalinks.

Basically I got everything to work, the only problem I'm facing is the permalink structure since the custom post type archive is a child page of another one. Another problem is when I use the read more tag it links to the archive permalink instead of the about parent page. So I get alot of 404's.

Is there a way to achieve this or am I asking too much from WordPress?

1 Answer

Try to set the permalink structure inside Wordpress to %postname% under Settings->Permalinks. Also every time you create a CTP or Custom Taxonomy, you must refresh the permalinks to get it to work.

Hope this helps! :)

Tried flushing the permalinks and it solves some issues, but it's still not working. I'll have to check out some other stuff first, it might be a problem with the CPT itself.

Can you please be more detailed and show us your code to help you furthermore? Also a safe way to create custom post types and taxonomies, is through the www.generatewp.com. It is a very good online tool and i recommend you to use it. Choose post type generator and fill all the necessary fields.

Hope this helps!