Advertisement
iftekharul

Insert ads in single post content

Jul 24th, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. add_filter( 'the_content', 'prefix_t4b_post_ads' );
  2. function prefix_t4b_post_ads( $content ) {
  3.     $ad_code = '<div id="t4b-post-ads">
  4.             <!-- Ad Start -->
  5.             // Paste here your Ads code
  6.             <!-- Ad End -->
  7.             <div class="post_ad_label">Advertise</div>
  8.             </div>';
  9.     if ( is_single() && ! is_admin() ) {
  10.         return prefix_t4b_after_paragraph( $ad_code, $content );
  11.     }
  12.     return $content;
  13. }
  14. function prefix_t4b_after_paragraph( $insertion, $content ) {
  15.     $paragraphs = $insertion . $content;
  16.     return $paragraphs;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement