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


Custom post type archive content.

I want to add some text as an introduction on a custom post type archive page. I can hard code it into the template, obviously, but I would prefer for it to be editable in the WP admin.

I know I can use is_post_type_archive(posttype) to identify the page as a cpt archive, but that's as far as I've got.

Anyone know how to do this (WITHOUT using a plugin)?


1 Answer

Justin Estrada
Justin Estrada
34,995 Points

Zac goes over how to create WordPress theme option pages here, using WordPress setting APIs: http://teamtreehouse.com/library/wordpress-settings-api

Thanks Justin, but that doesn't answer the question :)

Justin Estrada
Justin Estrada
34,995 Points

Give me more details on what you wish to do. "You said you don't want to hard code it into the them". Okay.

So this is for an archive page? I would cope the content within your main themes archive.php

Past it into your child theme's archive.php (create one if one doesn't exist). Then proceed to add the code you want.

I suggest this because you turned down my suggestion of making a theme options page for dynamically changing content on your site through the admin area.

Hope that helps

Thanks for the suggestions Justin, but I've actually found another way of solving the problem. If I don't set

 'has_archive' => true 

when creating the custom post type, it defaults to false, and I can then use a page template for the archive instead of an archive template.

This way, the content can be edited where anyone else using the theme would expect to find it.