Displaying woocommerce archive title and subtitle

Hi!

I’m currently setting up my archive page. I have moved the description under the product loop by adding this code to my functions.php file in my child theme:

 //move description to below the product loop 
    remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
    remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description', 10 );
    add_action( 'woocommerce_after_shop_loop', 'woocommerce_taxonomy_archive_description', 40 );
    add_action( 'woocommerce_after_shop_loop', 'woocommerce_product_archive_description', 40 );

I now also want to display the archive title and subtitle, which i added in the category settings. The title should be within an h1 tag and subheading within h2. How can i do this?

kindest regards,
Johan

Hello Johan,

Thanks for writing in! Regretfully, this particular customization request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with your customization of it. As such, you will need to investigate this particular issue on your own or seek help from a developer should you not feel comfortable making these changes yourself.

Meanwhile, I have difficulties in viewing your product page. I cannot scroll the page to see the bottom of the page. All because you have added this custom css:

html, body {
    overflow: hidden !important;
    height: 100% !important;
    background: none;
}

If you have any further questions about the theme, we are more than happy to provide you with assistance on these inquiries.

Thank you for your understanding.

Hi Rue Nel

That css is generated by the under construction plugin provided by the theme. Why is the page even visible without being logged in?

If you try logging in with the provided details, you should be able to scroll down.

My question is simply how do i display the archive title and subtitle?

Reading this article it seems to mention a solution for icon stack, but i’m using integrity. It also sounds like it’s only the icon stack that doesn’t display it, so i’m not sure what’s wrong. https://theme.co/apex/forum/t/show-woocommerce-category-title/5353

Thanks in advance for your help.

Hi Johan,

The code provided in the thread is only applicable for standard header, while your site uses a custom header created in Pro builder. You’ll have to re-create your header since it’s custom one, just like how content is created in the builder.

For that, the code from that thread should be converted to the shortcode, for example


function display_category_title(){ 

  if ( x_is_product_category() ) : 

    ob_start();

    $meta     = x_get_taxonomy_meta();
    $title    = ( $meta['archive-title']    != '' ) ? $meta['archive-title']    : __( 'Category Archive', '__x__' );
    $subtitle = ( $meta['archive-subtitle'] != '' ) ? $meta['archive-subtitle'] : __( "Below you'll find a list of all items that have been categorized as ", '__x__' ) . '<strong>&ldquo;' . single_cat_title( '', false ) . '&rdquo;</strong>';

    ?>

    <header class="x-header-landmark x-container max width">
    <h1 class="h-landmark"><span><?php echo $title ?></span></h1>
    <p class="p-landmark-sub"><span><?php echo $subtitle ?></span></p>
    </header>

    <?php 

    return ob_get_clean();

  endif;

}

add_shortcode('display_category_title', 'display_category_title');

Then in your header builder, you can add another header bar or just use existing header bar and add a text element. Then within that text element, add the shortcode [display_category_title]

This should only serve as the idea which you can improve but we can’t cover any customization related to it.

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.