Archived topic
Change the category pages using elements / hook
6 replies · Started by Anders Nielsen on May 7, 2022
Hi
I'm trying to make a blog category look like a "normal" page.
– So I want to remove all blogpost from it.
I have setup an element block – with my new design.
I'm trying to hook in the new design to that specific category page, but I can't find a hook – that inserts my content, and removes all the blogposts from the category view.
Can you help me locate the right hook for this?
I use generateblocks too.
Ok, found the "Template part" where I can overwrite the page.
But the category name (H1) is still there on the page – som hov do I remove it?
Hi there,
you can unhook the archive title:
add_action( 'after_setup_theme', function() {
if ( some_condition_is_met() ) {
remove_action( 'generate_archive_title', 'generate_archive_title' );
}
} );
Hi David
Thanks - but I got this error inserting the snippet in functions.php
`Uncaught Error: Call to undefined function some_condition_is_met() in wp-content/themes/generatepress/functions.php:125
Stack trace:
#0 wp-includes/class-wp-hook.php(307): {closure}('')
#1 wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
#2 wp-includes/plugin.php(474): WP_Hook->do_action(Array)
#3 wp-settings.php(565): do_action('after_setup_the...')
#4 wp-config.php(97): require_once('/home/goteam/do...')
#5 wp-load.php(50): require_once('/home/goteam/do...')
#6 wp-admin/admin.php(34): require_once('/home/goteam/do...')
#7 wp-admin/theme-editor.php(10): require_once('/home/goteam/do...')
#8 {main}
Sorry i was meant to say - you need to replace: some_condition_is_met() with the condition you want to make the change to.
eg.
add_action( 'after_setup_theme', function() {
if ( is_category() ) {
remove_action( 'generate_archive_title', 'generate_archive_title' );
}
} );
This will apply to only the Category archives ( not tags or other taxonomies ).
If you want to apply it to a specific category you can include its slug: is_category('the-category-slug')
Of this will remove it from all archives.
add_action( 'after_setup_theme', function() {
remove_action( 'generate_archive_title', 'generate_archive_title' );
} );
Awesome ... Now I understand, thanks :)
Glad to hear that!