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.


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!

  • For the title would it be 'get_title'? Is there any predefined shotcode? Thanks! – I.G. Pascual Feb 16 '12 at 11:30
  • 1
    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]. – fuxia 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. – fuxia 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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