- This topic has 8 replies, 4 voices, and was last updated 3 years, 3 months ago by
David.
-
AuthorPosts
-
March 12, 2020 at 11:20 pm #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() { ... }March 13, 2020 at 10:13 am #1194067Tom
Lead DeveloperLead DeveloperHi 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.
August 17, 2021 at 1:04 am #1898426David Perez Garcia
Did you make that filter?
August 17, 2021 at 1:15 am #1898434David Perez Garcia
August 17, 2021 at 7:45 pm #1899521Tom
Lead DeveloperLead DeveloperYes – you can now disable the default loop using that filter 🙂
March 3, 2023 at 1:31 am #2553690Nates
Please can provide a clear way to disable the loop in an archive on a all categories?
Where exactly is this code used? I tried the following in the functions.php
if (is_category()) { add_filter( 'generate_has_default_loop', '__return_false' ); }March 3, 2023 at 4:52 am #2553939David
StaffCustomer SupportHi there,
try this PHP Snippet:
add_filter( 'generate_has_default_loop', function($show){ if ( is_category() ) { return false; } return $show; } );March 4, 2023 at 10:27 pm #2555942Nates
Thanks I found a way.
March 5, 2023 at 6:23 am #2556242David
StaffCustomer SupportGlad to hear that
-
AuthorPosts
- You must be logged in to reply to this topic.