[Resolved] Disable Default Post List on Custom Category Archive with Page Hero

Home Forums Support [Resolved] Disable Default Post List on Custom Category Archive with Page Hero

Home Forums Support Disable Default Post List on Custom Category Archive with Page Hero

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2304238
    Chris

    I am trying to create a custom category archive using Page Hero. I got everything working using a dynamic title, dynamic description etc. The last thing I want to add is a ‘Query Loop’ showing all the posts in this category. No problem adding this, selecting ‘Inherit Query from Template’ it shows all the posts I need.

    The only problem I have now is that category archive still shows the default list of posts underneath all of this. I don’t see an option to disable them, at least not for a specific category. How do I change that?

    Am I using the correct approach and Element Type for this?

    I think the first part of the video covers it kind of: https://www.youtube.com/watch?v=8byA37OTBRg
    However, for some reason he only shows how to activate the final blog template and not how to create it.

    Edit: Found the solution in a different video: https://www.youtube.com/watch?v=gEuMXGHIa08
    Great solution you guys found for this, much better than what I tried!

    #2304253
    David
    Staff
    Customer Support

    Hi there,

    disabling the default loop can be done using the generate_do_template_part filter like so:

    add_filter( 'generate_do_template_part', function( $do ) { 
        if ( is_category() ){
            // if is category disable loop
            $do = false;    
        }
        return $do; 
    });

    Are you using the correct Element Type? Thats debatable 🙂
    In the next updates to GP / GP Premium we look to introduce a new Element Type, that will be used for creating templates like this, it will remove the theme loop so you can build whatever you like in the sites #page container.

    Using a Page Hero element type is the same as a Hook element type, just with some page hero specific stuff. But its HTML is output between the site header and the page container. If it doesn’t bother you that you have the HTML outside that and empty page container then go for it.

    Or you can use a Hook thats inside the main container.

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