Adding Content / Ads after or before the post in Wordpress
Open your theme editor in your Wordpress admin page, Appearance » Editor » from "Select them to edit" drop down (on the top right) make sure it's
If you wanted to add your text before the post.
function text_before_post_content($content){ if (is_single()) { $content = "<p>Hello,</p>" . $content; } return $content; } add_filter( "the_content", "text_before_post_content" );
If you wanted to add your text after the post.
function text_after_post_content($content){ if (is_single()) { $content = $content . "<p>Thanks for reading.</p>"; } return $content; } add_filter( "the_content", "text_after_post_content" );
If you wanted to add your text before and after the post.
function text_beforeafter_post_content($content){ if (is_single()) { $content = "<p>Hello,</p>" .$content . "<p>Bookmark this website.</p>"; } return $content; } add_filter( "the_content", "text_beforeafter_post_content" );
If you wanted to add your link after the post, you should write your double quotes and single quotes placement carefully.
function text_beforeafter_post_content($content){ if (is_single()) { $content = $content . "<p><a href='http://www.google.com'>Go to Google</a>."; } return $content; } add_filter( "the_content", "text_beforeafter_post_content" );
Hope this helps. To learn more about single and double quotes in PHP, http://php.net/manual/en/language.types.string.php
More..
More..