Title: Using [shortcode] in title.
Last modified: August 21, 2016

---

# Using [shortcode] in title.

 *  Resolved [energykick](https://wordpress.org/support/users/energykick/)
 * (@energykick)
 * [12 years, 12 months ago](https://wordpress.org/support/topic/using-shortcode-in-title/)
 * So far I love this plugin but I use shortcodes in my title and access them with
   get_the_title() which has always worked. I have the title to shortcode enabled
   on my site. My problem is I cannot figure out where (if it is possible) to change
   the title output to do my shortcode. I tried this:
 * `$zg_get_title = get_the_title($value+0);`
 * and this:
 * `echo "<a href=\"". get_permalink($value+0) . "\" title=\"". $zg_title_out->post_title."\"
   >". get_the_title($value+0) . "</a>\n";`
 * but both give a sql error so I am missing something about the loop. I would love
   to see if this can be done.
 * Thanks!
 * [http://wordpress.org/extend/plugins/last-viewed-posts/](http://wordpress.org/extend/plugins/last-viewed-posts/)

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

 *  Thread Starter [energykick](https://wordpress.org/support/users/energykick/)
 * (@energykick)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/using-shortcode-in-title/#post-3772348)
 * Now I have found some nice way to format my output with a photo and all like 
   this:
 *     ```
       echo "<div style=\"width: 550px;\"> <div style=\"float: left; width: 100px;\">";
       echo "<img class=\"floatLeft\" src=".get_the_post_thumbnail( $post_id, array(100,100));echo "</div> <div style=\"float: left; padding-left: 10px; width: 430px;\">";
       echo "<a href=\"". get_permalink($value+0) . "\" title=\"". $zg_title_out->post_title  . "\">". $zg_title_out->post_title . "</a>\n";
       echo "</div>";
       echo "<br style=\"clear: left;\" /><hr>";
       ```
   
 * but still cannot get the title to calculate my shortcode. I also tried this:
   `
   $zg_get_title = do_shortcode('[exercisetitle]');`
 * but it also gives and error. Does anyone have ideas how this can be done.
 * thanks!
 *  Plugin Author [Noumaan Yaqoob](https://wordpress.org/support/users/noumaan/)
 * (@noumaan)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/using-shortcode-in-title/#post-3772358)
 * Another neat way to do this is to find out the function used to add shortcode
   your will find function name in the add_shortcode line inside your functions.
   php or the plugin that generated the shortcode.
 * `add_action('exercisetitle', 'function_name');`
 * use that function like this
 * `$zg_get_title = function_name();`
 *  Thread Starter [energykick](https://wordpress.org/support/users/energykick/)
 * (@energykick)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/using-shortcode-in-title/#post-3772361)
 * Oh, thank you for answering so quick. I understand some things but not how the
   title shortcode works. I just added this to function.php
 * add_filter( ‘the_title’, ‘do_shortcode’ );
 * and it works. Do you know if there is a way I can use your $zg_get_title to tie
   into that somehow.
 * Thanks
    Rob

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

The topic ‘Using [shortcode] in title.’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/last-viewed-posts.svg)
 * [Last Viewed Posts by WPBeginner](https://wordpress.org/plugins/last-viewed-posts/)
 * [Support Threads](https://wordpress.org/support/plugin/last-viewed-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/last-viewed-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/last-viewed-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/last-viewed-posts/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [energykick](https://wordpress.org/support/users/energykick/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/using-shortcode-in-title/#post-3772361)
 * Status: resolved