• Resolved Warren

    (@rabbitwordpress)


    Hi there,
    I am trying to get this code to work in the WooCommerce description.php single product template:

    echo do_shortcode ('[expand title="Read more" swaptitle="Close"]');
    the_content();
    echo do_shortcode ('[/expand]'); 

    Do I need Collapse-Pro-Matic for this or should it work with the free version?

    I tried changing the Script Load Location and Shortcode Loads Scripts settings but it still doesn’t work.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author twinpictures

    (@twinpictures)

    if you use do_shorcode correctly, it will work with the free version.
    Try something like:

    $raw_content = get_the_content();
    $filtered_content = apply_filters('the_content', $raw_content);
    
    echo do_shortcode ('[expand title="Read more" swaptitle="Close"]'.filtered_content.'[/expand]');
    
    Thread Starter Warren

    (@rabbitwordpress)

    Fantastic!

    Thanks @twinpictures with a slight tweak changing .filtered_content. to . $filtered_content . it worked perfectly.

    For anyone else who might be interested; in my WooCommerce theme override at /single-product/tabs/description.php I changed the:

    <?php the_content(); ?>

    to this

    <?php 
    	$raw_content = get_the_content();
    	$filtered_content = apply_filters('the_content', $raw_content);
    	echo do_shortcode ('[expand title="Read more" swaptitle="Close"]'. $filtered_content .'[/expand]');
    ?>
    • This reply was modified 4 years, 4 months ago by Warren. Reason: added a semi colon
    • This reply was modified 4 years, 4 months ago by Warren. Reason: typo
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Collapse O Matic in WooCommerce description.php Template’ is closed to new replies.