Skip Navigation

[Resolved] Customize archive page

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 18 replies, has 2 voices.

Last updated by Jamal 3 years, 10 months ago.

Assisted by: Jamal.

Author
Posts
#1675199

Hi, thank you very much for your feedback and time,

No problem for the URL, how did you notice that one URL use the archive page and not the other ?

And the solution you provided is good but since the page is not full-width by default (we need a max-width because of products),
the header to will not take all the space available.

I found another way using hooks.
I used the articles you provided plus this one :
https://docs.woocommerce.com/document/conditional-tags/

add_action( 'astra_content_before', 'add_custom_header_on_woo_archives');

function add_custom_header_on_woo_archives() {
	if ( is_product_category() ){
        global $wp_query;
        $cat = $wp_query->get_queried_object();

        $bg_image = get_term_meta( $cat->term_id, 'wpcf-category-background-image', true );
        if ( $bg_image ) {
            echo '<div style="background:url(' . $bg_image . ') no-repeat center;background-size:cover;width:100%;text-align:center;">';
			echo '<h1 style="padding-top:4em;padding-bottom:4em;color:white;">'.$cat->name.'</h1>';
			echo '</div>';
        }
    }
    if ( is_shop() ) {
		// define a default image and title
    }
}

The only problem left is to get the correct image for shop page, I tried with this function

get_the_post_thumbnail_url();

but it returns the image of the first product, and not the featured image defined in shop page.

#1675253

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

That code seems a good solution too.

Check the following code if it is working for your shop page:

wp_get_attachment_url( get_post_thumbnail_id( wc_get_page_id( 'shop' ) ) );
#1675337

All right perfect!
It was the last missing piece.
My issue is resolved now. Thank you !

#1676491

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Awesome, I am glad I could help.

From you last message, you asked how did I knew that the archive page is using a Toolset template or not? I open the developers' tools in my browser and I check if the generated div/element has an ID of a template or not 😉

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.