Add page title as a javacript variable to specific posts

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.

Read More

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.

Related posts

Leave a Reply

1 comment

  1. 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!