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 very new to WordPress and I'm sorry if this question may sound ridiculous.

I need a way to add the post title into it's content, only in specific posts, and not always at the same place in the content. I've done some research, but all I find is about changing functions in .php files or in The Loop.

I don't know if there are any kind of predefined functions, tags or code that can be used to print this type of information manually into the content. I tried including <?php code, but obviously is not the way as it gets commented (please correct me if I'm wrong).

Ps: This is intended to be used by content publishers, SEOs, and people knowing almost nothing about programming.

share|improve this question
up vote 1 down vote accepted

Use a shortcode. In your plugin or theme (functions.php) add:

add_action( 'after_setup_theme', 'wpse_42534_add_permalink_shortcode' );
function wpse_42534_add_permalink_shortcode()
    add_shortcode( 'permalink', 'get_permalink' );

Now, your users can use the string [permalink] anywhere in the post to print the URI to the current post or page.

Oh, and welcome to WordPress Stack Exchange!

share|improve this answer
For the title would it be 'get_title'? Is there any predefined shotcode? Thanks! – I.G. Pascual Feb 16 '12 at 11:30
Yes, you can register any function which is returning a string as a shortcode callback handler. There are four predefined shortcodes: [gallery], [caption], [wp_caption] (an alias for caption) and [embed]. – toscho Feb 16 '12 at 11:37
In your theme it should be the functions.php. I made an edit to my answer to be more explicit. You may also just put the code in a separate file an drop the file in wp-content/mu-plugins/. It is an auto-loaded must use plugin then. – toscho Feb 16 '12 at 11:47
thanks! I'm testing it, plugin will come later, as I go more through it – I.G. Pascual Feb 16 '12 at 11:48
I cannot make it work, using add_shortcode( 'title', 'get_title' );, then posting [title] – I.G. Pascual Feb 16 '12 at 11:54

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.