WordPress – Page Title Shortcode
In some case you may need to create a custom shortcode that simply displays the title of a Page, Post or Custom Post Type entry. Creating WordPress shortcodes is a simple two step process. First you will want to add the function that creates your unique shortcode and then you will want to add some new classes to your stylesheet to customize how that shortcode looks on the front end. Below is an example of a basic shortcode. To enable it just paste the functions below into your themes functions.php file and then use the corresponding shortcode wherever you want the title to display within your site.
function post_title_shortcode(){
return get_the_title();
}
add_shortcode('page-title','post_title_shortcode');
Source: Stack Exchange

Leave a Reply
Want to join the discussion?Feel free to contribute!