New Landing How can we help? Themeforest Theme Support Neighborhood Add custom attribute below product title

Viewing 11 posts - 1 through 11 (of 11 total)
  • #60002
    Sean
    Member
    Post count: 116

    Is it possible to show a custom attribute below the Product Title on the product listing pages rather than the category?

    #60186
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    Which attribute would you like to display? Also please provide me with your link and I will try my best to provide a solution.

    – Kyle

    #60267
    Sean
    Member
    Post count: 116

    I have a custom attribute called “vehicle.”
    http://springrates.com

    I was able to add it onto the product page under the product title from a code snippet I found on stackoverflow. Not sure if it’s the best way.

    #60293
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please share your code so i can suggest about it .
    With Best Regards
    Swift Ideas

    #60382
    Sean
    Member
    Post count: 116

    I added the following on line 75 of wp-content/themes/neighborhood/single-product.php:
    (vehicle is the name of the custom attribute)

    <?php
    $vehiclevalues = get_the_terms( $product->id, 'pa_vehicle');
    
      foreach ( $vehiclevalues as $vehiclevalue ) {
        echo $vehiclevalue->name;
      }
    ?>
    #60384
    Sean
    Member
    Post count: 116

    Sorry– that was where I added it on the Product Details page. I still want to also add it on the product listing pages too such as when shown on a page like this:

    http://springrates.com/shop/

    #60483
    Sean
    Member
    Post count: 116

    Just an update. I used the same code I referenced aboved and the vehicle now shows up under the products too. I added this into.

    neighborhood/woocommerce/content/product.php

    #60825
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Is your problem solved now ?
    For single product detail page -:
    Please open to edit content-singel-product.php at /neighborhood/woocommerce/

    Find this code at line 56 
    <p itemprop="price" class="price"><?php echo $product->get_price_html(); ?></p>
    
    Replace with 
    <p itemprop="price" class="price"><?php echo $product->get_price_html(); ?>
    <?php $vehiclevalues = get_the_terms( $product->id, 'pa_vehicle');
    foreach ( $vehiclevalues as $vehiclevalue ) {echo $vehiclevalue->name;} ?> 
    </p>

    Hope it should work fine .
    Thanks

    #60865
    Sean
    Member
    Post count: 116

    Thanks!

    #60867
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Thanks Mohammad

    #60874
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Most welcome of all .
    Thanks 🙂
    With Best Regards
    Swift Ideas

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register