Title: Shortcode Function in Target Content
Last modified: September 26, 2017

---

# Shortcode Function in Target Content

 *  Resolved [laddersrus](https://wordpress.org/support/users/laddersrus/)
 * (@laddersrus)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/shortcode-function-in-target-content/)
 * Hi, I’ve just installed your plugin and I love it, it’s great – thanks!
    I’ve
   read the documentation and searched this forum, but I cannot find anything on
   what I want to achieve. I’ve created a function on my site and then added a shortcode
   for it with some attributes so that I can call it within the HTML editor of a
   WordPress page. Can you let me know if it’s possible to add the shortcode to 
   trigger my function in the Target Content section of your plugin please and if
   so, how I’d go about this? Many thanks
    -  This topic was modified 8 years, 8 months ago by [laddersrus](https://wordpress.org/support/users/laddersrus/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fshortcode-function-in-target-content%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [twinpictures](https://wordpress.org/support/users/twinpictures/)
 * (@twinpictures)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/shortcode-function-in-target-content/#post-9532282)
 * Not sure exactly what you mean by:
 * > possible to add the shortcode to trigger my function in the Target Content 
   > section of your plugin
 * Do you want the expand/collapse action to trigger a function, or do you simply
   want to place a shortcode in the hidden content of the expand element?
 * Can you provide a short example of the current expand shortcode structure you
   are using? Regardless, we’ll help get you sorted out and happy.
 *  Thread Starter [laddersrus](https://wordpress.org/support/users/laddersrus/)
 * (@laddersrus)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/shortcode-function-in-target-content/#post-9532362)
 * Thanks for your quick response! 🙂
 * My function reads a specific XML file (based on my shortcode attributes) that’s
   hosted in a folder inside the wp-includes directory of my WordPress site.
    The
   XML contains PDF/MP4 file names for files which are also stored in that folder
   which the function reads, then creates hyperlinks for each file so that the user
   can click to access/download them. These files (XML’s which kind of act as a 
   contents list, plus PDF’s and MP4’s) are synced from an external location to 
   my WordPress directory and there are new versions being added and old ones removed
   on a daily basis. There’s an automated process that runs on a server in the external
   location to update the XML’s, so that they only contain current file names.
 * The files are in 4 different categories… Briefs; Planograms; Useful Info & Videos
   and there can be quite a lot in each one.
    What I want to do is have each category
   listed as the visible title of a collapsible list, then when that category is
   clicked, my shortcode is triggered and the hyperlinks for the files within that
   category are displayed for the user to click.
 * Hope this makes a bit more sense.
    -  This reply was modified 8 years, 8 months ago by [laddersrus](https://wordpress.org/support/users/laddersrus/).
    -  This reply was modified 8 years, 8 months ago by [laddersrus](https://wordpress.org/support/users/laddersrus/).
 *  Plugin Author [twinpictures](https://wordpress.org/support/users/twinpictures/)
 * (@twinpictures)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/shortcode-function-in-target-content/#post-9532390)
 * So is your shortcode working like so:
 *     ```
       [super_duper_shortcode cat="briefs"/]
       ```
   
 * And this will list out all the links to your Briefs?
 * Please provide an example of how your shortcode works.
 *  Thread Starter [laddersrus](https://wordpress.org/support/users/laddersrus/)
 * (@laddersrus)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/shortcode-function-in-target-content/#post-9532412)
 * Yes, very much like that…
 * [filelinks client=”ClientA_(25)” type=”briefs” folder=”briefs”]
 * That example looks for the XML file based on the client and type attributes, 
   then creates the link using the client and folder attributes. They happen to 
   be the same here, but are not for all of the categories
    -  This reply was modified 8 years, 8 months ago by [laddersrus](https://wordpress.org/support/users/laddersrus/).
    -  This reply was modified 8 years, 8 months ago by [laddersrus](https://wordpress.org/support/users/laddersrus/).
 *  Plugin Author [twinpictures](https://wordpress.org/support/users/twinpictures/)
 * (@twinpictures)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/shortcode-function-in-target-content/#post-9532425)
 * And what happens with something like:
 *     ```
       [expand title="Client A Briefs"]
          [filelinks client="ClientA_(25)" type="briefs" folder="briefs" /]
       [/expand]
       ```
   
 * Note: Be sure to past this in the TEXT mode of the page editor so you don’t copy
   over any wonky text formatting and HTML bloat.
 *  Thread Starter [laddersrus](https://wordpress.org/support/users/laddersrus/)
 * (@laddersrus)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/shortcode-function-in-target-content/#post-9532450)
 * When I try that, the collapsible Title is displayed, however, the links are displayed
   above the title as soon as the page loads and the action of expanding and collapsing
   the Title does nothing, apart from change the direction of the arrow.
 *  Plugin Author [twinpictures](https://wordpress.org/support/users/twinpictures/)
 * (@twinpictures)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/shortcode-function-in-target-content/#post-9532457)
 * then check the following:
    1. make sure that your code is valid, terminated html
   2. check that your function is [not simply echoing the code](https://stackoverflow.com/questions/21538180/wordpress-using-echo-vs-return-in-shortcode-function),
   but building a complete string, finally returning that contents.
 *  Thread Starter [laddersrus](https://wordpress.org/support/users/laddersrus/)
 * (@laddersrus)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/shortcode-function-in-target-content/#post-9534307)
 * I have echoed the code so I think this is where the problem is. Thanks for the
   heads up. I’ll get my function changed and test again
 *  Plugin Author [twinpictures](https://wordpress.org/support/users/twinpictures/)
 * (@twinpictures)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/shortcode-function-in-target-content/#post-9534564)
 * Let us know if you get this resolved… but returning rather than echoing the results
   will most likely bring joy.
 *  Plugin Author [twinpictures](https://wordpress.org/support/users/twinpictures/)
 * (@twinpictures)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/shortcode-function-in-target-content/#post-9538195)
 * any progress to report?
 *  Thread Starter [laddersrus](https://wordpress.org/support/users/laddersrus/)
 * (@laddersrus)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/shortcode-function-in-target-content/#post-9538218)
 * Apologies, yes, it’s all sorted now and looking great.
    Thanks very much for 
   all your help, fantastic responses!
 *  Plugin Author [twinpictures](https://wordpress.org/support/users/twinpictures/)
 * (@twinpictures)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/shortcode-function-in-target-content/#post-9538235)
 * Great to hear you got it worked out.
    If you are happy with the plugin or the
   support, consider [leaving a little review](https://wordpress.org/support/plugin/jquery-collapse-o-matic/reviews/).
   Issue marked as resolved.

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

The topic ‘Shortcode Function in Target Content’ 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/)

 * 12 replies
 * 2 participants
 * Last reply from: [twinpictures](https://wordpress.org/support/users/twinpictures/)
 * Last activity: [8 years, 8 months ago](https://wordpress.org/support/topic/shortcode-function-in-target-content/#post-9538235)
 * Status: resolved