• Resolved kahoferj

    (@kahoferj)


    Collapse-o-matic is working just fine in my php template-file when I hard-code the “hidden” text:

    <?php echo do_shortcode(‘[expand title=”DESCRIPTION”]description[/expand]’); ?>

    But what I’d really like to do is have the text in a variable:

    <?php $x=the_content();
    echo do_shortcode(‘[expand title=”DESCRIPTION”]$x[/expand]’); ?>

    Why doesn’t that work?! What should I be doing?

    Thanks!

    https://www.ads-software.com/plugins/jquery-collapse-o-matic/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Baden

    (@baden03)

    <?php
    $content = apply_filters( 'the_content', get_the_content() );
    $content = str_replace( ']]>', ']]>', $content );
    echo do_shortcode('[expand title="DESCRIPTION"]'.$content.'[/expand]');
    ?>

    You will want to read more on get_the_content

    Thread Starter kahoferj

    (@kahoferj)

    Thank you so much!

    Hello,

    long time after the original question but I encounter almost same problem:

    I need to put the shortcode in my php code but the content is something like:

    <form action="" class="myclass" method="mypost" enctype='multipart/form-data'>
    <table width="100%" class="myclass2">
    		<?php
    
    		foreach ( $args as $item) {
    <tr>
    
    					<td>
    </td>
    </tr>
    </table>
    </form>
    }

    Any help ?

    Plugin Author Baden

    (@baden03)

    Hi. this thread is resolved, so best to start a new one.
    keep in mind, the code you included, is not logical, as it will loop through the items and keep closing your table and form.

    if you do start a new thread, please be very detailed in what you are trying to achieve.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Collapse-o-matic in a php template – use a variable?’ is closed to new replies.