- This topic has 6 replies, 2 voices, and was last updated 3 years, 11 months ago by
David.
-
AuthorPosts
-
May 7, 2022 at 2:06 am #2212202
Anders Nielsen
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.
May 7, 2022 at 2:12 am #2212207Anders Nielsen
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?
May 7, 2022 at 3:57 am #2212279David
StaffCustomer SupportHi 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' ); } } );May 7, 2022 at 5:17 am #2212330Anders Nielsen
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}May 7, 2022 at 5:43 am #2212349David
StaffCustomer SupportSorry 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' ); } );May 7, 2022 at 5:45 am #2212352Anders Nielsen
Awesome … Now I understand, thanks 🙂
May 7, 2022 at 6:01 am #2212361David
StaffCustomer SupportGlad to hear that!
-
AuthorPosts
- You must be logged in to reply to this topic.