in the wordpress admin, i would like to do the following when creating a page:
Page Title: Test
Page content:
Lorem ipsum dolor [page_title] sit amet, consectetur adipiscing elit. Nunc et lectus sit amet ante vulputate ultrices at sit amet [page_title] tortor. Nam mattis commodo mi in semper. Suspendisse ut eros dolor. Morbi at odio feugiat [page_title] nunc vestibulum venenatis sit amet vitae neque. Nam ullamcorper ante ac risus malesuada id iaculis nibh ultrices.
Where it says [page_title] I would like it to print the page title (Test)
This needs to be achieved through the admin system, not hard-coded in the template.
Refer to the codex: Shortcode API
Add this to your theme’s functions.php file.
Note that per the comments exchange between S.Visser and I in his answer – this solution will only work inside The Loop, while his will also work outside The Loop and so his is the more complete answer.
Add this to your theme, or make an plugin from it.
Found this solution on web hope it will help others who face the same problem as mine. Just add the below code to functions.php file or to the page_title plugin .php file.