Title: Collapse element in php file
Last modified: August 20, 2016

---

# Collapse element in php file

 *  Resolved [massimocasini](https://wordpress.org/support/users/massimocasini/)
 * (@massimocasini)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/collapse-element-in-php-file/)
 * Hello, and thanks for the great pugin!
 * I need to collapse/expand an element in a theme file (a page template).
    It works
   in the php file with <php echo do_shortcode(‘[expand title=”Trigger Text”][/expand]’);
   but I need to enclose some lines of code with <? php… ?> tags. As soon as I try
   and put php within the shortcode tags it returns a syntax error.
 * This is the code i am trying to enclose (in a file called “template-services.
   php”)
 *     ```
       <div id="white" class="clearfix">
       	<div id="container">
       				<php global $post;
       				if(get_post_meta($post->ID, 'wpcf-brand-band-txt', true) != ''):
       					echo get_post_meta($post->ID, 'wpcf-brand-band-txt', true);
       				endif; ?>
         	</div>
       </div>
   
       <div id="gray" class="clearfix">
       	<div id="container-1">
       		<div id="white-band">
       			<h1>
       			<?php if(get_post_meta($post->ID, 'wpcf-quote-teaser-1', true) != ''):
       				echo get_post_meta($post->ID, 'wpcf-quote-teaser-1', true);
       			endif; ?>
       			<a class="quoterequest" href="#">REQUEST A QUOTE</a>
       			</h1>
   
       		</div>
       	</div>
       </div>
       ```
   
 * Any idea how to work around that?
 * Thank you so much!!!!!!!
 * [http://wordpress.org/extend/plugins/jquery-collapse-o-matic/](http://wordpress.org/extend/plugins/jquery-collapse-o-matic/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Baden](https://wordpress.org/support/users/baden03/)
 * (@baden03)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/collapse-element-in-php-file/#post-3497908)
 * In this case, we assume that you are adding the collapse element to your template.
   
   It seams you have two ways of doing this: 1. assign the results of `template-
   services.php` to a variable and then use the variable in a normal do_shortcode
   call of the shortcode. 2. read up on the [roll-your-own method](http://plugins.twinpictures.de/plugins/collapse-o-matic/documentation/#roll-your-own)
   of assembling collapse elements, and simply include or echo your special php 
   file where you want.
 * Please do let us know if you achieved success in this endeavor.

Viewing 1 replies (of 1 total)

The topic ‘Collapse element in php file’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/jquery-collapse-o-matic_fffeff.svg)
 * [Collapse-O-Matic](https://wordpress.org/plugins/jquery-collapse-o-matic/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/jquery-collapse-o-matic/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/jquery-collapse-o-matic/)
 * [Active Topics](https://wordpress.org/support/plugin/jquery-collapse-o-matic/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/jquery-collapse-o-matic/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/jquery-collapse-o-matic/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Baden](https://wordpress.org/support/users/baden03/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/collapse-element-in-php-file/#post-3497908)
 * Status: resolved