Home Forums WoodMart support forum Adding H1 tags to WooCommerce product pages

Adding H1 tags to WooCommerce product pages

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #498022

    maxnieuwenhuijs
    Participant

    example:
    https://werkschoen.nl/werkschoenen-sneakers/page/2/

    I’m working on a WooCommerce website, and I need to add an H1 tag on all product archives pages (see example). This is important for SEO purposes.

    I was wondering what would be the best way to implement this?

    #498027

    maxnieuwenhuijs
    Participant

    add_action( ‘woocommerce_archive_description’, ‘add_h1_to_archive’, 2 );

    function add_h1_to_archive() {

    // Controleer of het de eerste pagina is
    if ( get_query_var( ‘paged’ ) <= 1 ) {
    return; // Als het de eerste pagina is, doe dan niets
    }

    if ( is_search() ) {
    $title = __(‘Search results for “‘, ‘woocommerce’) . get_search_query() . ‘”‘;
    } elseif ( is_tax() ) {
    $title = single_term_title( ”, false );
    } else {
    $title = woocommerce_page_title();
    }

    echo ‘<h1>’ . $title . ‘</h1>’;

    }

    #498231

    You are Most Welcome.

    We are glad that you managed to solve the problem yourself. You are Great!!!

    Let us know if there’s anything else we can do for you! You can always reach us at any time. We are always here to help you.

    Have a wonderful day.

    Topic Closed.
    Best Regards.

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Adding H1 tags to WooCommerce product pages’ is closed to new replies.