• Resolved iamahmedq

    (@iamahmedq)


    Hi,

    Could you please help me with this? I tried the following code to echo this shortcode in order to display the brands before product title. But it didn’t work.

    add_action( 'woocommerce_before_shop_loop_item_title', 'aq_display_brand_before_title', 10, 0 );
    function aq_display_brand_before_title() {
    	echo do_shortcode('[pwb-brand]');
    }

    If you can add an option in backend this will allow users to display it according to their needs. But I guess brand name should go first in loop before the product title. On single product options are great.

    Overall this plugin is great. However the documentation needs to be improved a little.

    Thanks

    The page I need help with: [log in to see the link]

Viewing 15 replies - 31 through 45 (of 63 total)
  • alexdex

    (@alexdex)

    Hi, i have the same problem, if i add this code The brand name appear on top of the product image and the link point to the brand and not to the product

    The code that is working well is this (BUT how add a class here)

    add_action( ‘woocommerce_before_shop_loop_item_title’, ‘aq_display_brand_before_title’ );
    function aq_display_brand_before_title(){
    global $product;
    $product_id = $product->get_id();
    $brands = wp_get_post_terms( $product_id, ‘pwb-brand’ );
    foreach( $brands as $brand ) echo ‘<p>’.$brand->name.'</p>’;
    }

    Thread Starter iamahmedq

    (@iamahmedq)

    add_action( ‘woocommerce_before_shop_loop_item_title’, ‘aq_display_brand_before_title’ );
    function aq_display_brand_before_title(){
    global $product;
    $product_id = $product->get_id();
    $brands = wp_get_post_terms( $product_id, ‘pwb-brand’ );
    foreach( $brands as $brand ) echo ‘<p class="YourClassName">’.$brand->name.'</p>’;
    }

    If it displays a brand name, perhaps it has already an assigned class/id to it.

    alexdex

    (@alexdex)

    Hi, thanks for your help but I received a php error, the function is not correct unfortunately

    Please let me know

    alexdex

    (@alexdex)

    Hi, I copy and paste and the quote was wrong, your code work GREAT

    Thanks a lot

    Thread Starter iamahmedq

    (@iamahmedq)

    @alexdex Glad it worked for you.

    gguidi

    (@gguidi)

    Hi @titodevera
    I’m trying to achieve what @iamahmedq asked but without the link to the Brand Page.

    I tried to add the code you suggested:

    add_action( 'woocommerce_before_shop_loop_item_title', 'aq_display_brand_before_title' );
     function aq_display_brand_before_title(){
       global $product;
       $product_id = $product->get_id();
       $brands = wp_get_post_terms( $product_id, 'pwb-brand' );
       foreach( $brands as $brand ) echo '<p>'.$brand->name.'</p>';
     }

    But even if i didn’t put the ‘<a href=” the link is still present.
    Do you have any idea on why that’s happening?

    Website: https://www.bibimima.com/categoria-prodotto/donna/abbigliamento/

    Thanks

    roannamedina

    (@roannamedina)

    Hi,

    I still haven’t figured it out.

    I copied this code below and the brand name still shows up on top of our product image.. how to fix this?

    I’d prefer it be shown below the image
    Website: https://www.humblemarket.ph/shop/

    
    add_action( 'woocommerce_before_shop_loop_item_title', 'aq_display_brand_before_title' );
     function aq_display_brand_before_title(){
       global $product;
       $product_id = $product->get_id();
       $brands = wp_get_post_terms( $product_id, 'pwb-brand' );
       foreach( $brands as $brand ) echo '<p>'.$brand->name.'</p>';
     }
    
    
    Thread Starter iamahmedq

    (@iamahmedq)

    Hi @roannamedina,

    Try replacing the hook with
    woocommerce_after_shop_loop_item_title or
    woocommerce_shop_loop_item_title

    You can also make small adjustments with CSS once you get the brand name on the right location.

    Pufak

    (@pufak)

    Hello all

    @roannamedina

    here’s what you all look for:

    add_action('woocommerce_after_shop_loop_item_title', function(){
      echo do_shortcode('[pwb-brand product_id="'.get_the_ID().'" as_link="true"]');
    });

    add the code above in your function.php

    greeting from Cairo, Egypt with ??

    • This reply was modified 5 years ago by Pufak.
    • This reply was modified 5 years ago by Pufak.

    Link still there tho..even with the: `” as_link=”false”

    ??

    • This reply was modified 4 years, 12 months ago by gguidi.

    I tried this code
    but still it is not showing brand name

    add_action( ‘woocommerce_before_shop_loop_item_title’, ‘aq_display_brand_before_title’ );
    function aq_display_brand_before_title(){
    global $product;
    $product_id = $product->get_id();
    $brands = wp_get_post_terms( $product_id, ‘pwb-brand’ );
    foreach( $brands as $brand ){
    echo ‘term_id).'” class=”category uppercase is-smaller no-text-overflow product-cat op-7″>’;
    echo $brand->name;
    echo ‘
    ‘;
    }
    }

    add_action( ‘woocommerce_before_shop_loop_item_title’, ‘aq_display_brand_before_title’ );
    function aq_display_brand_before_title(){
    global $product;
    $product_id = $product->get_id();
    $brands = wp_get_post_terms( $product_id, ‘pwb-brand’ );
    foreach( $brands as $brand ) echo ‘<p>’.$brand->name.'</p>’;
    }

    This code is not working
    https://www.socialbrandingplatform/e-style/shop

    this code is not working
    add_action( ‘woocommerce_before_shop_loop_item_title’, ‘aq_display_brand_before_title’ );
    function aq_display_brand_before_title(){
    global $product;
    $product_id = $product->get_id();
    $brands = wp_get_post_terms( $product_id, ‘pwb-brand’ );
    foreach( $brands as $brand ) echo ‘<p>’.$brand->name.'</p>’;
    }

    See the URl

    https://socialbrandingplatform.com/e-style/shop

    • This reply was modified 4 years, 9 months ago by manojjoshi.

    Hi!
    I tried to use the code below on my website, but it doesn’t work. Can you help me?
    The demo website: https://simoneboccuzzi.com/demo/shop

    THANK YOU!

     add_action( 'woocommerce_before_shop_loop_item_title', 'aq_display_brand_before_title' );
     function aq_display_brand_before_title(){
       global $product;
       $product_id = $product->get_id();
       $brands = wp_get_post_terms( $product_id, 'pwb-brand' );
       foreach( $brands as $brand ){
         echo '<a href="'.get_term_link($brand->term_id).'" class=“brandshoppage”>’;
          echo $brand->name;
         echo '</a>';
       }
     }
    Thread Starter iamahmedq

    (@iamahmedq)

    @simoneboccuzzi

    Please try this.

    add_action('woocommerce_after_shop_loop_item_title', function(){
      echo do_shortcode('[pwb-brand product_id="'.get_the_ID().'" as_link="true"]');
    });
Viewing 15 replies - 31 through 45 (of 63 total)
  • The topic ‘Display brand link/name before product title in loop’ is closed to new replies.