• 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 - 1 through 15 (of 63 total)
  • Plugin Contributor titodevera

    (@titodevera)

    Hi iamahmedq.

    You can try something like this:

    
     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)

    Thank you it worked but I guess it removed the link.

    It’s here.
    https://zoja.ae/

    Plugin Contributor titodevera

    (@titodevera)

    Replace

    '<p>'.$brand->name.'</p>'

    for

    '<a href="'.get_term_link($brand->term_id).'">'.$brand->name.'</a>'

    ??

    Thread Starter iamahmedq

    (@iamahmedq)

    Thank you for all your help. One simple question.
    I need to assign class to your recently provided code how can I do that?
    Here are the classes I want to assign your href code.
    class=”category uppercase is-smaller no-text-overflow product-cat op-7″

    Plugin Contributor titodevera

    (@titodevera)

    Simply add them to the <a> tag. Full code bellow:

    
     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="category uppercase is-smaller no-text-overflow product-cat op-7">';
          echo $brand->name;
         echo '</a>';
       }
     }
    

    ??

    Thread Starter iamahmedq

    (@iamahmedq)

    Thank you <3

    Plugin Contributor titodevera

    (@titodevera)

    You are welcome!

    ??

    Thread Starter iamahmedq

    (@iamahmedq)

    There are few other things that I noticed with the plugin.
    1) If you have brands in sidebar and you visit a certain brand page brands from sidebar will disappear.

    2) here
    anchor links are slightly acting weird.

    3) Would be great to have support for menu items with brand image.

    The plugin is awesome. I know it’s free just helping you with reporting bugs and improvements.

    Thanks

    hello tito,

    i want to achieve the same on my website.
    i allready applied the code.

    this is the site: https://www.yellowpomelo.net/shop

    unfortunatly the title know is directly under the image how can i move it close to the poduct titel and away from the image?

    would be great if you could help.

    thank you,
    david

    Hi, I saw this topic and realized that with the plug-in only I have the brand name above the product title in the loop. Unfortunately it’s not working on the single product page. Am I doing something wrong? Thank you ??

    Thread Starter iamahmedq

    (@iamahmedq)

    @laureenschein @davidbeger
    The code goes in functions.php file under your primary or child theme.
    If you do not have child theme it is good to create one.

    @iamahmedq i did that, but for a reason i do not know the brand name is know in the product photo container. on your page it is not. would you have an idea how to fix that. your help is very much appreciated!!

    Thread Starter iamahmedq

    (@iamahmedq)

    @davidbeger Looks fine for me.
    https://ibb.co/G9m1YrH
    Please send me screenshot so that I can help with CSS.

    i would love to have a small space between the picture and the brand name!

    or get move the titl closer to the brand name

Viewing 15 replies - 1 through 15 (of 63 total)
  • The topic ‘Display brand link/name before product title in loop’ is closed to new replies.