Site logo

Archived topic

Apply Sections to Custom Post Types?

6 replies · Started by Daniel Walker on October 19, 2015

Viewing posts 1–7 of 7

Hi Tom, is it possible to apply Sections to custom post types?

Thanks,
Dan

Hi Dan,

You should be able to do something like this:

add_filter( 'generate_sections_post_types','generate_add_section_post_types' );
function generate_add_section_post_types()
{
      return array( 'page','post','yourposttype' );
}

Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/

Perfect. And thanks for the speedy response.

Dan

Happy to help :)

Hi Tom, I didn't notice a side effect of adding Sections to custom post types until today: it stops custom post archive pages from displaying all pages of that custom post type. Only the newest page using Sections is displayed when you navigate to siteURL/category/customposttype/

If all my pages for a custom post type don't use Sections then the archive (archive-customposttypename.php) displays correctly and shows the headings and excerpts for all of those posts.

Is there something I can add to my archive-customposttype.php template to get it to ignore the Section content and display as an 'archive'?

Kind regards,
Dan

Hi Dan,

This is an issue with using Sections with posts/post types that display archives.

I'll have to come up with a way to remove items using Sections from those lists completely, as I don't see a way of them fitting into a blog post layout.

I'll look into this and get back to you :)

Hi Daniel,

This should be fixed in the latest version :)

This archived topic is closed to new replies.