[Resolved] Create element for categorie product

Home Forums Support Create element for categorie product

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #908558
    Sonia

    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

    #908700
    David
    Staff
    Customer Support

    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;
    }
    #909521
    Sonia

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

    That’s great.;)

    #909529
    David
    Staff
    Customer Support

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.