Okay
  Public Ticket #865425
Product Attributes
Closed

Comments

  • Justin started the conversation

    We're nearly ready to launch the site -- it's been great working with the Aurum theme! 

    I have one last question and I hope you can please guide me:

    I am trying to display a product attribute beneath the title and category for each book/product on this page: http://waitfortheword.com/books.

    The attribute field is: attribute:pa_selected

    I have tried *everything* and I cannot figure out how to add this to the template. I have broken the theme probably a dozen times and wasted over an hour! 

    Can you please guide me? Is there a hook that needs to be added to content-product.php in order to output this field?

    Thanks so much for your help. Sorry to bother you!

  • [deleted] replied

    Hi Justin,

    Can you please add the following code in functions.php (end of file):

    // Display Custom Attributes
    function woocommerce_display_custom_attributes() {
    	global $product;
    	
    	?>
    	<div class="product-attr-description">
    		<?php echo get_the_term_list( $product->ID, 'pa_selected', '', ', ' ); ?>
    	</div>
    	<?php
    }
    
    add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_display_custom_attributes' );
    This will show custom product attributes below the category.
  • Justin replied

    Thank you that worked beautifully! Is there any way to make it so that the attribute is not a LINK?

    http://waitfortheword.com/nps-books/

  • Justin replied

    An unrelated but really critical bug: for some reason the Testimonials carousel won't display the Featured Image: 

    http://nationalpoetryseries.org/testimonials-test/

    Any idea what's going on here? 

  • [deleted] replied

    Hi Justin,

    If you want to remove the links from the product attributes, replace that code with this one below:

    // Display Custom Attributes
    function woocommerce_display_custom_attributes() {
    global $product;

    ?>
    <div class="product-attr-description">
    <?php echo strip_tags( get_the_term_list( $product->ID, 'pa_selected', '', ', ' ) ); ?>
    </div>
    <?php
    }

    add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_display_custom_attributes' );

    As for testimonials page I was not able to see the page, it shows me a 404 error.

  • Justin replied

    Hi, that worked perfectly!

    I was able to solve the testimonial issue -- it was a server problem.

    Thanks so much. Great theme!

  • [deleted] replied

    Hi Justin,

    Great to hear that!

    If you like our theme, it would help us a lot if you could give us five star rating on themeforest from your Downloads tab, (if you don't know how, just open this link).

    A huge thank you from Laborator in advance!