WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to use WordPress template tags (through shortcodes) to merge the post title and url into hyperlink html code. Which looks like this:

<a href="[Permalink]">[Post Title]</a>.

Problem is the text output uses curly quotes around the "Permalink" that are not compatible with html code. I tried placing hyperlink code using template tags (shortcodes) into a code snippet box, however then the shortcodes won't run.

I would like to merge the template tags (through shortcodes) into the hyperlink html code first, then have it show up in a code snippet box. Any ideas on how to do that?

share|improve this question
up vote 0 down vote accepted

Just tested this and it worked on my end. The shortcode itself would be [titlelink]

function titlelink_ssc($content = null) {

        echo '<a href="'.get_permalink().'" title="'.get_the_title().'">'.get_the_title().'</a>';
        $titlelink_ssc = ob_get_clean();
        return $titlelink_ssc;

add_shortcode("titlelink", "titlelink_ssc");
share|improve this answer
Why do you do the ob_start() and echo instead of just returning the string? – Jan Fabry May 19 '11 at 18:32
Hmm...now that you ask, I'm not sure. I guess I've just always included the ob_start() in my shortcode functions. I believe it's mainly due to the fact that most of the shortcode functions I write involve adding a secondary loop. – Norcross May 20 '11 at 7:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.