• Resolved andsfdf3

    (@andsfdf3)


    Hey. Thanks for the plugin.

    I’m shocked. Why the hell is it so hard !? I am not prepared in php. I read all the answers on this forum and and experimented with code for many hours, but I could not do the simplest thing that could be:
    Display description
    Display image
    Display banner

    I found the answer how to display a description:

    
    //Brand description shortcode
    function custom_pwb_brand_info() {
      //show brand description
        if( is_product_taxonomy() ){
        $brands = wp_get_post_terms( get_the_ID(), 'pwb-brand' );
        foreach( $brands as $brand ) {
          echo '<p>'.$brand->description.'</p>';
        }   
      }
    }
    add_shortcode( 'custom_pwb_brand_info', 'custom_pwb_brand_info' );
    

    Where can I add this code to display a brand image?

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

    And how can I display banner images?

    // And further. I add a filter pwb_description_allowed_tags in functions.php and it does not work!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter andsfdf3

    (@andsfdf3)

    
    //Brand hero page shortcode
    function custom_pwb_brand_info() {
        if( is_product_taxonomy() ){
        $brands = wp_get_post_terms( get_the_ID(), 'pwb-brand' );
        
        foreach( $brands as $brand ) {
          $attachment_id = get_term_meta( $brand->term_id, 'pwb_brand_image', true );
          $attachment_src = wp_get_attachment_image_src( $attachment_id,'full' );
          $brand_banner_id = get_term_meta($brand->term_id, 'pwb_brand_banner', true);
          $brand_banner_src = wp_get_attachment_image_src( $brand_banner_id,'full' );
          echo '<div class="row align-items-center">';
          echo '<div class="col-12 col-sm-6 text-center">';
          echo '<img src="'.$attachment_src[0].'" alt="">';
          echo '<p>'.$brand->description.'</p>';
          echo '</div>';
          echo '<div class="col-12 col-sm-6">';
          echo '<img src="'.$brand_banner_src[0].'" alt="">';
          echo '</div>';
          echo '</div>';
        }
      }
    }
    add_shortcode( 'custom_pwb_brand_info', 'custom_pwb_brand_info' );
    
    Thread Starter andsfdf3

    (@andsfdf3)

    Now everything works for me on the local server. And on the hosting does not work. Shortcode displays nothing. What could be the reason?

    
    <?php echo do_shortcode('[custom_pwb_brand_info]') ?>
    
    • This reply was modified 5 years, 11 months ago by andsfdf3.
    Plugin Contributor titodevera

    (@titodevera)

    Hi andsfdf3.

    PWB can display by itself brand description and banner on each brand archive page, go to WooCommerce > Settings > Show brand description and configure it before or after the product loop.

    ??

    Hello!

    I’d like to thank you, @andsfdf3 for your codes! It helped me place a thumbnail on the archive page for the each of the brands I used.

    Here’s the screenshot of how it looked.

    Off-topic: I am now looking for a way to change the breadcrumb from ‘Brands” to ‘Artists’. Hopefully @titodevera can point me to the right direction. Your plugin is hands-down the best I’ve seen related to WooCommerce brands.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Description, image and banner’ is closed to new replies.