-
airbag41
Is there a filter I can use in function to set the category title to h2? I like to set my h1 separated using the description on the category to put in an h1 and text, but the output of the category title as an h1 is throwing that off.
Thanks
-
Hi there,
Do you mean the category title on the category archive page?
The easiest option is to create a block element – page hero for the category archives.
Then you can define the category title as h2.
https://www.screencast.com/t/Hxyiu55r3cHere’s a screenshot for the H2 title configuration:
https://www.screencast.com/t/kkjicoqA3Here’s a screenshot for the description configuration:
https://www.screencast.com/t/5r6mbDccPLet me know if this helps!
-
airbag41
Hi Ying, I appeciate the help. I actually don’t like using the blocks elements, so I just wanted to know where I can switch the category title on the category page to an h2 from an h1. Can this be done with a php filter?
-
There isn’t an easy filter for this, here’s the functions you will need to change it from h1 to h2:
function remove_generate_archive_title() { remove_action( 'generate_archive_title', 'generate_archive_title', 10 ); } add_action( 'after_setup_theme', 'remove_generate_archive_title' ); function h2_archive_title() { ?> <header <?php generate_do_attr( 'page-header' ); ?>> <?php /** * generate_before_archive_title hook. * * @since 0.1 */ do_action( 'generate_before_archive_title' ); ?> <h2 class="page-title"> <?php the_archive_title(); ?> </h2> <?php /** * generate_after_archive_title hook. * * @since 0.1 * * @hooked generate_do_archive_description - 10 */ do_action( 'generate_after_archive_title' ); ?> </header> <?php } add_action( 'generate_archive_title', 'h2_archive_title', 10 );
-
airbag41
ok thanks, I thought it would be simple but I will give this a try. Thanks again.
-
airbag41
worked thanks
-
No Problem 🙂
- You must be logged in to reply to this topic.