php - How to include page title of wordpress post in the content possibly with a shortcode -
in wordpress admin, following when creating page:
page title: test
page content:
lorem ipsum dolor [page_title] sit amet, consectetur adipiscing elit. nunc et lectus sit amet ante vulputate ultrices @ sit amet [page_title] tortor. nam mattis commodo mi in semper. suspendisse ut eros dolor. morbi @ odio feugiat [page_title] nunc vestibulum venenatis sit amet vitae neque. nam ullamcorper ante ac risus malesuada id iaculis nibh ultrices.
where says [page_title] print page title (test)
this needs achieved through admin system, not hard-coded in template.
refer codex: shortcode api
function myshortcode_title( ){ return get_the_title(); } add_shortcode( 'page_title', 'myshortcode_title' );
add theme's functions.php file.
Comments
Post a Comment