• 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 - 16 through 30 (of 63 total)
  • Thread Starter iamahmedq

    (@iamahmedq)

    .qodef-pl-image img {
        margin-bottom: 20px !important;
    }

    @davidbeger add above CSS code in your child theme’s style.css file.
    Adjust according to your requirement.

    @iamahmedq thank you so much, that works! your help is very much appreciated!!!

    Hi. Please I need help on getting the same you made on your site: putting the brand name before the product title. I can’t Make It To Work. I am not so good using php but here is what I did.

    I used the code in the function.php of my child theme:

    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 it doesn’t work. Here is a screenshot: https://ibb.co/KLyzVjZ

    I tried this code too:

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

    But when I try to save it gives me an error:
    Object of class WP_Error could not be converted to string

    Please help me. I really love this plugin

    UPDATE: I know I am stupid… I was yousing another plugin with similiar name… Switched to this and it works

    • This reply was modified 5 years, 5 months ago by newraiden.
    • This reply was modified 5 years, 5 months ago by newraiden.
    Thread Starter iamahmedq

    (@iamahmedq)

    Did you fix it?

    @newraiden

    @iamahmedq Please do you have any idea why the code is not working for me?

    I tried this one:

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

    Thanks.

    • This reply was modified 5 years, 2 months ago by samuelalake.

    I want to do the same to our website but the brand goes above the product image. Could someone help with a fix for this please?

    Here is a screenshot of how it looks with the code above: https://paste.pics/ed3d0dbe0e27f904f27cc640f00586b3

    Cheers,
    Ro

    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>'.$brand->name.'</p>';
     }

    Please add this code in functions.php and also play around with settings in the backend.
    Hopefully, it helps.
    Thanks
    Ahmed Q.

    @iamahmedq Thank you, but it is not working for me. It puts the brand name on top of the image like so: https://paste.pics/e88c902148c0c81af33b32cdae274c24

    We are hoping to bring the brand name down below the product image if this is possible?

    Thank you,
    Ro

    Thread Starter iamahmedq

    (@iamahmedq)

    Please share your website URL.

    I’m sorry.. We have not published our website just yet. It is private and only accessible by administrators.

    samuelng527

    (@samuelng527)

    Hi,

    anyone can help to align the brand name which is njow above the product title and adjust the gap below the brand name and the product title.

    you guys may view at https://culturecartel.com/brand/culture-cartel/

    And 1 more thing, when on the signle product page, how can the brand display on the product name?

    Please advise, many thanks!

    samuelng527

    (@samuelng527)

    Hi,

    anyone can help to align the brand name which is njow above the product title and adjust the gap below the brand name and the product title.

    you guys may view at https://culturecartel.com/brand/culture-cartel/

    And 1 more thing, when on the single product page, how can the brand display on the product name?

    Please advise, many thanks!

    Thread Starter iamahmedq

    (@iamahmedq)

    Hi @samuelng527,

    Use the following CSS in AVADA Theme Option>Custom CSS

    .product-cat {
        font-size: 16px;
        margin-bottom: 20px;
    }

    I resized the font so it looks slightly different than the product title you can remove it if you are happy.

    Second one: https://culturecartel.com/wp-admin/admin.php?page=wc-settings&tab=pwb_admin_tab
    on this page ‘Show brands in single product’ choose one option from dropdown brand Link or Image or None.

    Thanks
    Ahmed Q.

    samuelng527

    (@samuelng527)

    Hi @iamahmedq ,

    Thank you so much for your advice.

    samuelng527

    (@samuelng527)

    Hi,

    I have added the below 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’ );
    foreach( $brands as $brand ){
    echo ‘term_id).'” class=”category uppercase is-smaller no-text-overflow product-cat op-7″>’;
    echo $brand->name;
    echo ‘
    ‘;
    }
    }

    The brand name appear on top of the product image which I want it to appear top of the product title and below the product image.

    Please help. Many thanks.

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