• 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 - 46 through 60 (of 63 total)
  • Hi!

    I would like to display a product tag below the image along with the title. I know that the hook is woocommerce_shop_loop_item_title but if i use it, it makes a mess. Same happens if i use the hook woocommerce_after_shop_loop_item, only with the hook woocommerce_after_shop_loop_item_title the tags are displayed under the price. I used the code below:

    add_action( 'woocommerce_after_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, 'product_tag' );
       foreach( $brands as $brand )
    	 echo '<p class="t-entry-text">'.$brand->name.'</p>';	 
     }
    

    Is it possible to apply it site widely?
    Any help would be appreciated.

    Thank you

    Update:
    It is placed in the wrong class, can you assist me in assigning echo to the correct div or class please ?

    Thank you.

    @nsekeris
    I’d like to the similar thing, Did you figure it out?

    Thread Starter iamahmedq

    (@iamahmedq)

    @nsekeris and @pirate_hj use priority when calling the function to display the brand where you need it.

    A quick example:
    add_action( 'woocommerce_single_product_summary', "show_digital_price", 10 );

    You can also check the priority of product title and make sure it is greater than the title to appear first.

    Let me know if that helps.

    Thanks @iamahmedq for quick reply

    Is there a way putting brand link between product title and product excerpt on archive page? I use short description instead of long one and it already shows excerpt in less than 2 columns.

    This is what it looks like

    Product Title
    Short Description
    Add to Cart

    This is what I want

    Product Title
    Brank Link
    Short description
    Add to Cart

    I’ve tried this code but the brand link sat after short description

    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).'">'.$brand->name.'</a><br>';
     }
    Thread Starter iamahmedq

    (@iamahmedq)

    @titodevera
    Could you please help @pirate_hj ?

    @pirate_hj @iamahmedq

    No, i didn’t. When i use the hook woocommerce_after_shop_item_title it is displayed below the price, with the hook woocommerce_before_shop_item_title it is displayed above the product image and with the hook woocommerce_shop_item_title the page is messed up.

    The priority didn’t work for me.

    Solved my issue by asking to my theme’s support team.
    For me it’s fine if the brand name places under the title so this codes helped me, priority 16 was the key.

    
    add_action( 'woocommerce_shop_loop_item_title', 'aq_display_brand_before_title', 16 );
     function aq_display_brand_before_title(){
       global $product;
       $product_id = $product->get_id();
         $product_excerpt = $product->post->post_excerpt;
       $brands = wp_get_post_terms( $product_id, 'pwb-brand' );
       foreach( $brands as $brand ) echo '<div class="brand_stie"><span>brands: </span><a href="'.get_term_link($brand->term_id).'">'.$brand->name.'</a></div>';
     }
    

    Hi,

    I am using Rehub Theme. I want to dispaly Brand name below image or Below Price in the product Archive. I activated “Perfect Brands for WooCommerce” plugin and added following code in child theme’s function.php file. But it still not displaying brand name in product loops. Please Help.

    Website Link: https://www.giftrepository.com/product-category/new-arrivals/

    Code added in function.php:
    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 ‘
    ‘;
    }
    }

    Hello there i am trying to achieve the same result , but I am using woocomerce brands not perfect brands. Both plugins are by woocomerce . There might be a little change in the code you sent. Can you please make it for that

    Robert

    (@roberthedlund)

    @titodevera

    Hi

    Im new to this plugin, is it possible to show the brand name before the title on every product when using category blocks?

    I would like to have that way, any idea?

    Appreciate any help.

    Hello,

    is there any snippet where i can show a tagline with every product title?
    e.g product name – tagline

    Waiting for your kind response.

    Thanks

    Hey Guys,
    I’m still trying to make this work …

    I tried to figure out how to integrate the brand name in the complete shop in the product title, started with the single product page. But in fact I guess, it may be a easier solution to integrate it all over the shop in the product title, what I want.

    Could you please help me?

    This is, what I tried:

    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_title’, 5 );
    add_action( ‘woocommerce_single_product_summary’, ‘aq_display_brand_before_title’, 5 ); );
    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
    ‘<h1 class=”product_title entry-title”>’;

    if( $brand->name )
    echo ‘ – ‘ . $brand->name;
    the_title();
    echo ‘</h1>’;
    }

    I usw Enfold in the actual version and WordPress incl. all plugins too.

    Thank you all in advance for any advice on how this could be solved.

    All the best,
    Chris

    Dear @titodevera

    Thanks for the help. I’m trying to show the brands logo-thumbnail instead of the brand name (still with the link).

    How do I have to modify your code?

    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' );
       $attachment_src = wp_get_attachment_image_src( $attachment_id,'full' );
       foreach( $brands as $brand ) echo '<a href="'.get_term_link($brand->term_id).'">'.$brand->name.'</a>';
     } 

    I wasn’t able to reproduce it with following terms. It shows always empty or error.

    
    $attachment_id = get_term_meta( $brand->term_id, 'pwb_brand_image', true );
    $attachment_src = wp_get_attachment_image_src( $attachment_id,'full' );
    

    Thanks for the help.

    Greetings Elìa

    Hi, i am going crazy for make it work.My template is using custom woocommerce template file and not exist the hook woocommerce_before_shop_loop_item_title

    I want to display before my thumbnail on the shop page and the template is using woocommerce_template_loop_product_thumbnail

    So i change the code in this way:

    // add brand name before title wine
    add_action( 'woocommerce_template_loop_product_thumbnail', 'aq_display_brand_before_title , 10, 0' );
     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="alexbrand">'.$brand->name.'</p>';
     }

    Nothing happen, no error, no brand visible at all. Please help me

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