Viewing 15 replies - 1 through 15 (of 21 total)
  • im looking for this too ! somebody know. .??

    Here’s the solution I came up with. This goes in your theme’s functions.php:

    add_action('add_meta_boxes', 'product_title_desc_box');
    add_action('save_post', 'product_title_desc_save', 1, 2);
    
    function product_title_desc_box(){
        add_meta_box('product_title_desc_box', 'Product Title Description', 'product_title_desc_form', 'product','side', 'core');
        wp_nonce_field( basename( __FILE__ ), 'smashing_post_class_nonce' );
    }
    function product_title_desc_form($post){
        wp_nonce_field( basename( __FILE__ ), 'product_title_description_nonce' );
        $value = get_post_meta($post->ID, 'title-description', true);
        ?> <p><label for="title-description">Enter a short description to be displayed below the title in the catalog pages</label>
            <br />
            <input type="text" name="title-description" id="title-description" value="<?php echo $value ; ?>"/>
        </p>
        <?php
    }
    
    function product_title_desc_save($post_id, $post ){
        if(!isset( $_POST['title-description']) || !wp_verify_nonce($_POST['product_title_description_nonce'], basename(__FILE__)))
                    {
            return $post_id;
                    }
                     $post_type = get_post_type_object( $post->post_type );
    
        /* Check if the current user has permission to edit the post. */
        if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
            return $post_id;
    
                    $description = $_POST['title-description'] ;
                     update_post_meta( $post_id, 'title-description', $description);
    
    }
    add_action('woocommerce_after_shop_loop_item_title','add_title_description',9);
    function add_title_description(){
      echo get_post_meta($product->id, 'title-description', true)? '<span class="title-description">' . get_post_meta($product->id, 'title-description', true) . '</span><br />' : '';
    }

    you’ll find a new “Product Title Description” field on your post edit screen

    Thread Starter webow

    (@webow)

    I don’t see “Product Title Description”. Upload same screenshot…

    I would be interested if anyone knows how to apply this to the output of widgets, like the Best Sellers widget. I have it on my redesigned company site, and left space for a short except.

    http://184.154.165.114/~cusackef/cusackmusic.com/

    There’s no clean way to do this as that widget doesn’t use any filter or action hooks and no template files

    Temporarily, you could modify woocommerce/widgets/widget-best_sellers.php
    by replacing this line:

    </a> <?php echo $product->get_price_html(); ?></li>

    with this:

    </a> <?php echo get_post_meta($product->id, 'title-description', true)? '<span class="title-description">' . get_post_meta($product->id, 'title-description', true) . '</span><br />' : '';
    
     echo $product->get_price_html(); ?></li>

    but it’s probably a better idea to create a plugin to essentially duplicate this widget with your customizations

    Yeah, I thought that might be the case. I did something similar to your temporary solution and lost my changes on the last update. Stupid newb mistake. Live and learn I guess. Thanks.

    Same here, I see no “Product Title Description” field on the post edit screen! ;(

    I after paste the your code i can see the “Product Title Description” , but after saving the product i can’t see any desc after title….i paste the code at the end of the function.php before the php close tag “?>”..
    why i can see the “product title description” but it didn’t work…
    I cried when I saw the description field, because they are many weeks that I try to solve the problem ….but didn’t work…Why in your opinion?
    Sorry for my english…

    @cjubewa:
    that chunk of code only adds a field for a postmeta value. You also have to modify something else to display that value.

    where do you want to display it? category/archive pages? single product page? both? something else?

    Hi !!! I want to display it in shop page (listing page) before the add to cart button…This for give more information before the client click the product to enter in the single product page…Thanks for your answer !!

    Hi , can you give me an example how to call that value in shop page? Thanks!

    If i paste in content-product.php this code i can see short description in te right place..
    what is the name of the value that I have to call to see the text that I wrote in the box that I have created with your code?

    code that call short description:

    <?php echo $product->get_sku(); ?>

    <?php echo apply_filters( ‘title-description’, $post->post_excerpt ) ?>

    Hope you help me i want to use your solution….

    hey i used the code below to show product description short but it shows the complete descripion no restricting the description to few words. its showing all the content of product description but i want to show only few text and then view more link.
    below is code help me soon if you can.

    “><h3><?php the_title(); ?></h3>

    <?php echo apply_filters( ‘woocommerce_short_description’, $post->post_excerpt ) ?>

    “>Read More >>

    this code i used but show full i need to show few and then full on view more.

    There is a “Product Short Description” on the product edit page, which is really just the excerpt for that custom post type. Here’s how to add it to the list page:

    add_action( 'woocommerce_after_shop_loop_item_title', 'my_add_short_description', 9 );
    function my_add_short_description() {
    	  echo '<span class="title-description">' . the_excerpt() . '</span><br />';
    }
Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Short description below product’ is closed to new replies.