Archived topic
How to Use Elements with Custom Post Type Archive Pages
16 replies · Started by Allison on May 26, 2019
Hey,
So I'm working on a site that has some custom post types setup via a plugin (past developer work). I'm looking to set some custom headers via elements for the custom post type category archive page but it won't let me. It works fine for a custom post type single post but not the category archive page. I set the location to Resource Category and then selected the category name and it won't work.
Any suggestions?
Thanks,
Allison
Hi there,
Can you try this filter:
https://docs.generatepress.com/article/generate_header_element_display/
With this conditional tag?
https://codex.wordpress.org/Conditional_Tags#A_Post_Type_Archive
Let me know if this helps :)
I applied the filter and tag and it removed the header from showing on a single custom post type but still nothing is showing on the custom post type category page.
Can you link me to the page where you want the header element to show?
I edited my initial post to include the URL, please be careful not to post it anywhere as it's sensitive information for a client site I'm working on. Resource Categories: Guides, Webcasts
Custom post type: Events are the ones I am having trouble with.
The site requires a password to view. Can you provide it?
You can send the dashboard access using Account Issue here:
https://generatepress.com/contact/
Please include the following information:
– The URL of this topic.
– Login URL.
– Username and password.
Hi Leo,
I sent the information you require via the account issue contact form. Let me know when you are finished as I'll have to delete that user account afterwards.
What is the code you've tried?
What about this?
add_filter( 'generate_header_element_display', function( $display, $element_id ) {
if ( 10 === $element_id && is_tax( 'qsc_resource_category' ) ) {
$display = true;
}
return $display;
}, 10, 2 );
Make sure to replace 10 with the actual ID.
While a filter like that should work, it shouldn't be necessary. The Display Rules should work with custom post types as long as they're set up correctly.
Can you share a screenshot of your Display Rules?
Hi Tom,
Here is a sceenshot for the display rules for the custom post type category Guides. The page hero won't show up.
So that will apply to posts inside that category.
Try "Resource Category Archive".
Doesn't work, I even tried making my own custom post type archive and it still won't work. Screenshot of settings
Hmm, what happens if you create a Hook Element using a test hook (before_header) with the same Display Rules? Does it display?
The hook works, just tested it with some words
Good news.
Any other Header Elements on the site? If so, can you set them to "Draft" temporarily to see if one of them is conflicting?: https://docs.generatepress.com/article/conflicting-display-rules/