• Resolved ridersjin

    (@ridersjin)


    Hi,
    I have used the code below to add long description on the shop page but the first 2 lines are not below the title product. How can I fix this issue ?

    add_action( 'woocommerce_after_shop_loop_item_title', 'wc_add_long_description',2 );
    
    function wc_add_long_description() {
    	global $product;
    
    	?>
            <div itemprop="description">
                <?php echo apply_filters( 'the_content', $product->get_description() ) ?>
            </div>
    	<?php
    }
    

    Find below a screenshot for more details of the issue
    https://ibb.co/b5yMc5Y

    Thanks in advance


Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @ridersjin

    I have used the code below to add long description on the shop page but the first 2 lines are not below the title product. How can I fix this issue?

    From what I understand, you’re trying to get the product description to show up under the product title on your shop page. Looking at your code, everything appears in order, but the priority you’ve assigned to the ‘woocommerce_after_shop_loop_item_title‘ action could be the issue.

    In your code, the priority is ‘2’. This could be why the description is showing up before other elements that also use this action. Try bumping up the priority to a higher number, like ’20’. This should ensure your description shows up after the product title and other elements:

    add_action( 'woocommerce_after_shop_loop_item_title', 'wc_add_long_description', 20);
    
    function wc_add_long_description() {
    	global $product;
    
    	?>
            <div itemprop="description">
                <?php echo apply_filters( 'the_content', $product->get_description() ) ?>
            </div>
    	<?php
    }

    If this doesn’t fix the issue, your theme’s CSS might be interfering with the layout. You can use your browser’s inspect tool to see the CSS rules applied to these elements and adjust as needed. Don’t forget to clear your cache after making changes to make sure you’re seeing the updated version of your site.

    ?? Just a heads up – while we’re always here to assist you, our scope of support doesn’t extend to custom development or design patterns, which includes troubleshooting or giving specific advice on using custom action hooks or filters.

    For custom solutions, our recommendation is to connect with Codeable.io, our trusted WooCommerce development partner. They’re experts in crafting custom solutions for WooCommerce and might be able to help you develop a custom solution for your problem. Check them out here: ?? https://woocommerce.com/codeable

    I hope this helps! If you have any other questions or need more assistance, don’t hesitate to ask.

    Thread Starter ridersjin

    (@ridersjin)

    Hi Tamrat,
    Thank you for your prompt reply.
    When i change the priority more than 5. I have the price above the description. See screenshot below
    https://ibb.co/gMqbZNN
    I want the the description is between the title and the price.
    May be there is a CSS code to add in style.css to fix this issue ?
    Thanks in advance for your help

    Plugin Contributor royho

    (@royho)

    Hi @ridersjin,

    You can give this a try:

    add_action( 'woocommerce_after_shop_loop_item_title', 'wc_add_long_description' );
    
    function wc_add_long_description() {
    	global $product;
    
    	?>
            <div itemprop="description" style="clear:both;">
                <?php echo apply_filters( 'the_content', $product->get_description() ) ?>
            </div>
    	<?php
    }
    Thread Starter ridersjin

    (@ridersjin)

    Hi Royo,
    After added the priority to 2. It works !
    Thank you so much ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display long description on shop page’ is closed to new replies.