Title: linuxplayground's Replies | WordPress.org

---

# linuxplayground

  [  ](https://wordpress.org/support/users/linuxplayground/)

 *   [Profile](https://wordpress.org/support/users/linuxplayground/)
 *   [Topics Started](https://wordpress.org/support/users/linuxplayground/topics/)
 *   [Replies Created](https://wordpress.org/support/users/linuxplayground/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/linuxplayground/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/linuxplayground/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/linuxplayground/engagements/)
 *   [Favorites](https://wordpress.org/support/users/linuxplayground/favorites/)

 Search replies:

## Forum Replies Created

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

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Custom Content Type Manager] How do I call a template for the shortcode](https://wordpress.org/support/topic/how-do-i-call-a-template-for-the-shortcode/)
 *  Thread Starter [linuxplayground](https://wordpress.org/support/users/linuxplayground/)
 * (@linuxplayground)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/how-do-i-call-a-template-for-the-shortcode/#post-3183798)
 * Have raised issue on google code wiki here:
    [http://code.google.com/p/wordpress-custom-content-type-manager/issues/detail?id=427](http://code.google.com/p/wordpress-custom-content-type-manager/issues/detail?id=427)
 * Marking this thread as resolved.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Custom Content Type Manager] How do I call a template for the shortcode](https://wordpress.org/support/topic/how-do-i-call-a-template-for-the-shortcode/)
 *  Thread Starter [linuxplayground](https://wordpress.org/support/users/linuxplayground/)
 * (@linuxplayground)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/how-do-i-call-a-template-for-the-shortcode/#post-3183784)
 * OK – I think I have it resolved. I had to edit your code. Never a good thing 
   for me because when you update the plugin, my edits will all be gone. But it’s
   that important to me.
 * After much inserting of var_dump($blah); exit; lines I figured out what was happening.
 * The changes I made are as follows:
 * 1. In the get posts function I included a block to unset $raw_args[‘tpl’] as 
   follows (just after the block that unsets the help option… 🙂 :
 *     ```
       //added code to unset tpl from raw_args so it's not used in filter.
               if (isset($raw_args['tpl']) ) {
                   unset($raw_args['tpl']);
               }
       ```
   
 * 2. I had to change the test order for the template. So the heirachy is: if there
   is a template argument, try to use it. If not or it fails to load the template
   then look for the $content value. If that’s not provided then use the default
   or if it is provided, read it and parse the bit between the open and close shortcode.
 * Here is the new function:
 *     ```
       //------------------------------------------------------------------------------
           //! Private functions
           //------------------------------------------------------------------------------
           /**
            * Get the template (tpl) to format each search result.
            *
            * @param string  $content
            * @param array   $args    associative array
            * @return string
            * EDIT - DAVID LATHAM - Changed order of test for empty(content) and
            *                       empty(args[tpl])
            */
           private static function _get_tpl($content, $args) {
               $content = trim($content);
               if( !empty($args['tpl']) ) {
                   // strip possible leading slash
                   $args['tpl'] = preg_replace('/^\//', '', $args['tpl']);
                   $file = ABSPATH .$args['tpl'];
   
                   if ( file_exists($file) ) {
                       $content = file_get_contents($file);
                   }
                   else {
                       // TODO: throw an error
                   }
               }
               elseif ( empty($content) ) {
                   $content = self::result_tpl; // default
               }
               // Read from between [summarize-posts]in between[/summarize-posts]
               else {
                   $content = html_entity_decode($content);
                   // fix the quotes back to normal
                   $content = str_replace(array('”', '“'), '"', $content );
                   $content = str_replace(array('‘', '’'), "'", $content );
               }
               return $content;
           }
       ```
   
 * Maybe you want to give this some review time, and possibly include it in your
   next update? Otherwise – I will have to stick with this version or update your
   next update to suite…
 * I really like the idea of handing out this short code to the editors and having
   the template take care of itself. Maybe it’s something we could load into the
   database even from the manager side. But that’s for another rainy day. I don’t
   care about it ***THAT*** much.. 🙂
 * Regards
    David Latham
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Custom Content Type Manager] How do I call a template for the shortcode](https://wordpress.org/support/topic/how-do-i-call-a-template-for-the-shortcode/)
 *  Thread Starter [linuxplayground](https://wordpress.org/support/users/linuxplayground/)
 * (@linuxplayground)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/how-do-i-call-a-template-for-the-shortcode/#post-3183781)
 * Sorry – here is the SQL it generated:
 * `SELECT wp_8_posts.ID FROM wp_8_posts LEFT JOIN wp_8_term_relationships ON wp_8_posts.
   ID=wp_8_term_relationships.object_id LEFT JOIN wp_8_term_taxonomy ON wp_8_term_taxonomy.
   term_taxonomy_id=wp_8_term_relationships.term_taxonomy_id LEFT JOIN wp_8_terms
   ON wp_8_terms.term_id=wp_8_term_taxonomy.term_id LEFT JOIN wp_8_postmeta ON wp_8_posts.
   ID=wp_8_postmeta.post_id WHERE ( 1 AND (wp_8_postmeta.meta_key = 'tpl' AND wp_8_postmeta.
   meta_value = 'wp-content/themes/fastfood-child/bios.tpl') AND wp_8_posts.post_type
   NOT IN ('revision','nav_menu_item') AND wp_8_posts.post_type IN ('bio') AND wp_8_posts.
   post_status IN ('publish','inherit') AND wp_8_term_taxonomy.taxonomy = 'post_tag'
   AND wp_8_terms.name IN ('farm') ) GROUP BY wp_8_posts.ID ORDER BY wp_8_posts.
   menu_order ASC`
 * Its adding the value of my template to a where clause… Huh?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Custom Content Type Manager] How do I call a template for the shortcode](https://wordpress.org/support/topic/how-do-i-call-a-template-for-the-shortcode/)
 *  Thread Starter [linuxplayground](https://wordpress.org/support/users/linuxplayground/)
 * (@linuxplayground)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/how-do-i-call-a-template-for-the-shortcode/#post-3183780)
 * First of all – Good morning 🙂 (its night time over in New Zealand)
 * I guess the closing quotes was just a typo when completing the post.
    After posting
   this I added a help=1 option to the short code and this appeared:
 * Shortcode:
    `[summarize-posts offset="" orderby="menu_order" orderby_custom=""
   order="ASC" post_type="bio" taxonomy="post_tag" taxonomy_term="farm" tpl="wp-
   content/themes/fastfood-child/bios.tpl" help=1]`
 * Relevant part of response:
 * > Summarize Posts
   >  Errors There were no errors. Warnings Search parameters ignored:
   > search_term and search_columns must be set. Notices
   >  -  Filtering on direct column/value: tpl: = wp-content/themes/fastfood-child/
   >    bios.tpl
   > Execution Time
   >  0.01 seconds Arguments orderby: menu_order order: ASC post_type:
   > Array (bio) omit_post_type: Array (revision, nav_menu_item) post_status: Array(
   > publish, inherit) taxonomy: post_tag taxonomy_term: Array (farm) taxonomy_depth:
   > 1 search_columns: Array (post_title, post_content) join_rule: AND match_rule:
   > contains date_column: post_modified tpl: wp-content/themes/fastfood-child/bios.
   > tpl
 * Its that line, “Filtering on direct column/value” that is worrying me.
 * Maybe a cup of espresso will help clear things up ? 🙂
 * Thanks for your help.
    Regards David Latham

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