Site logo

Archived topic

Create element for categorie product

3 replies · Started by Sonia on May 23, 2019

Viewing posts 1–4 of 4

Hello
I'm coming back to you because I want to create something like the "Single Post Entry Header" theme "Merch" but for product categories in woo commerce. Can you tell me how to create one? The php calls the pages "taxonomy-product_cat.php" to display the product categories. thank you

Hi there,

so you could try this - which is sort of the other way around to how the posts work.

First:
1. Create a new Header Element
2. Content:

<h1>{{post_title}}</h1>
{{custom_field.description}}

3. Set your top bottom padding around 100px, set center alignment and then set the Display Rules to Product Category Archive

Second:
1. Create a new Hook Element
2. Content:

<?php
global $wp_query;
$cat = $wp_query->get_queried_object();
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );
if ( $image ) {
	echo '<div class="grid-container prod-cat-header-img"><img src="' . $image . '" alt="' . $cat->name . '" /></div>';
}
?>

3. Select the after_header hook.
4. Check execute PHP
5. Set the priority to 15
6. Set the same display rules as above.

Then add this CSS:

.prod-cat-header-img.grid-container {
    padding-left: 0;
    padding-right: 0;
}

Hi
Thank you very much for your help, it works perfectly.

That's great.;)

Thats awesome - i originally abandoned the idea when building Merch - so glad you asked and we have a good solution

This archived topic is closed to new replies.