[Resolved] How to Use Elements with Custom Post Type Archive Pages

Home Forums Support [Resolved] How to Use Elements with Custom Post Type Archive Pages

Home Forums Support How to Use Elements with Custom Post Type Archive Pages

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #911588
    Allison

    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

    #911608
    Leo
    Staff
    Customer Support

    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 πŸ™‚

    #912328
    Allison

    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.

    #912380
    Leo
    Staff
    Customer Support

    Can you link me to the page where you want the header element to show?

    #912411
    Allison

    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.

    #912543
    Leo
    Staff
    Customer Support

    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.

    #912637
    Allison

    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.

    #913484
    Leo
    Staff
    Customer Support

    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.

    #913788
    Tom
    Lead Developer
    Lead Developer

    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?

    #913821
    Allison

    Hi Tom,

    Here is a sceenshot for the display rules for the custom post type category Guides. The page hero won’t show up.

    #914473
    Tom
    Lead Developer
    Lead Developer

    So that will apply to posts inside that category.

    Try “Resource Category Archive”.

    #914687
    Allison

    Doesn’t work, I even tried making my own custom post type archive and it still won’t work. Screenshot of settings

    #914823
    Tom
    Lead Developer
    Lead Developer

    Hmm, what happens if you create a Hook Element using a test hook (before_header) with the same Display Rules? Does it display?

    #914844
    Allison

    The hook works, just tested it with some words

    #914853
    Tom
    Lead Developer
    Lead Developer

    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/

Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.