How to add contents to the wordpress page or post using hooks.You can add before content or after content of the posts.Wordpress hooks are easy to handle and add contents without worrying.Mostly wordpress hooks are using to WordPress plugin developers.
Two types of hooks named “Actions and Filters”.
Actions: Actions are the hooks that the WordPress core launches at specific points during execution, or when specific events occur.
Filters: Filters are the hooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browser screen.
Add contents to the page or post using hooks
add_filter( 'the_content', 'my_function' , 20 ); function my_function($content) { $custom_content = 'CONTENT GOES HERE'; // TO ADDING BEFORE CONTENT $content = $custom_content.$content; return $content; }
Add contents after page content
add_filter( 'the_content', 'my_function' , 20 ); function my_function($content) { $custom_content = 'CONTENT GOES HERE'; // TO ADDING AFTER CONTENT $content = $content.$custom_content; return $content; }
Add contents after page or post in thesis theme
add_action('thesis_hook_after_post', 'my_function'); function my_function() { echo 'CONTENT GOES HERE'; }
WordPress add custom text after post title in Thesis theme
WordPress add custom text after site name in Thesis theme
WordPress add custom text into the Thesis theme footer