[Support request] How do I disable the loop on an archive?

Home Forums Support How do I disable the loop on an archive?

  • This topic has 1 reply, 2 voices, and was last updated 1 year ago by Tom.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1193463
    Nates

    Hi

    On a category or tag page, I don’t want to display the normal posts. I want to disable it, is it possible via hook/filter without having to create a category.php and tags.php in a child theme.

    When a category page loads, I want to display my own thing, compltely custom code. I am currently using genesis framework and would like to move to Generate Press.

    I do the following in genesis. Firstly, disable the loop (genesis_loop), then create an action to add my own function instead – audio_player().

    Can this be achieved in GP?

    add_action('genesis_before_content_sidebar_wrap', 'qc_category_player');
    function qc_category_player()
    {
        if (is_category()) {
            remove_action('genesis_loop', 'genesis_do_loop'); // Remove the standard loop
            add_action('genesis_loop', 'audio_player'); // Add custom output
        }
    }
    
    function audio_player()
    {
    
    ...
    
    }
    
    
    #1194067
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    This isn’t possible at the moment, unfortunately.

    However, I’ve made a note to add a filter in GP 2.5.0 so we can disable the standard loop. This will be important moving forward with some of our own plans, as well.

    For now, a custom page template is the best method.

    You could create a new template, then do this:

    add_filter( 'template_include', function( $template ) {
        if ( is_category() ) {
            return locate_template( 'your-blank-template.php' );
        }
    
        return $template;
    } );

    That way you don’t need to overwrite the standard theme template.

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