Title: Pass function thru shortcode
Last modified: August 20, 2016

---

# Pass function thru shortcode

 *  Resolved [presquillian](https://wordpress.org/support/users/presquillian/)
 * (@presquillian)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/pass-function-thru-shortcode/)
 * I love this plugin! I’m just having a bit of trouble accomplishing one thing.
   How may I accomplish something like the following:
 *     ```
       <?php
       echo do_shortcode('[expand title="Title" expanded="true" tag="div" trigpos="below" swaptitle="Off"]<?php
       $post_id = 454;
       $queried_post = get_post($post_id);
       ?>
       <h2><?php echo $queried_post->post_title; ?></h2>
       <?php echo $queried_post->post_content; ?>[/expand]');?>
       ```
   
 * I’m trying to pass a function to grab post content- out side of a post or page.
   I can’t seem to get the post content to work. Is there a better way to accomplish
   this? Thanks so much for your help!
 * Also- I’m trying to use an image as the title- similar to this example
    [expand
   title=”<img src=’falcon_girl.jpg’ />” tag=”div”]Target Content[/expand] when 
   I try this outside a post or page and using a full URL – no image appears
 *     ```
       <?php
       echo do_shortcode('[expand title="<img src="http://site.com/content/uploads/11/image.jpg" expanded="true" tag="div" trigpos="below" swaptitle="Off"]...[/expand]');?>
       ```
   
 * Thanks again. Keep up the great work!
 * [http://wordpress.org/extend/plugins/jquery-collapse-o-matic/](http://wordpress.org/extend/plugins/jquery-collapse-o-matic/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [presquillian](https://wordpress.org/support/users/presquillian/)
 * (@presquillian)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/pass-function-thru-shortcode/#post-3169712)
 * Never mind! I’m all set.
 *     ```
       <div id="target-test" class="collapseomatic_content">
       <?php
       $post_id = 454;
       $queried_post = get_post($post_id);
       echo $title;
       echo $queried_post->post_content;
       ?>
       </div>
       <span title="Results" class="collapseomatic" id="test"><img src="http://site.com/content/uploads/2012/11/Untitled-1.png"></span>
       <span id="swap-test" class="collapseomatic" style="display: none;">Close</span>
       ```
   
 *  Plugin Author [Baden](https://wordpress.org/support/users/baden03/)
 * (@baden03)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/pass-function-thru-shortcode/#post-3169714)
 * Thumbs up for figuring it out!
 *  [uamv](https://wordpress.org/support/users/uamv/)
 * (@uamv)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/pass-function-thru-shortcode/#post-3169727)
 * [@presquillian](https://wordpress.org/support/users/presquillian/): You might
   find this plugin of use, as well … [Collapse-O-Collection](http://uam.vandercar.net).
   i’ve just recently been working on it.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Pass function thru shortcode’ 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/)

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [post_content](https://wordpress.org/support/topic-tag/post_content/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 3 replies
 * 3 participants
 * Last reply from: [uamv](https://wordpress.org/support/users/uamv/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/pass-function-thru-shortcode/#post-3169727)
 * Status: resolved