Skip to content

Instantly share code, notes, and snippets.

@ThomasKujawa
Created December 11, 2014 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasKujawa/f1cba766e97613113999 to your computer and use it in GitHub Desktop.
Save ThomasKujawa/f1cba766e97613113999 to your computer and use it in GitHub Desktop.
Wordpress | Toolbox | #AD nach MORE-Break
<?php
/*
Module Name: Werbung nach dem more break
Module URI: http://linuxundich.de/webhosting/anzeige-nach-dem-more-break-einer-wordpress-seite-automatisch-einfugen/
Description: Fügt nach dem MORE-Break Werbung oder Shortcode ein. [Frontend]
Author: Christoph Langner
Author URI: http://linuxundich.de/author/christoph/
*/
/* Sicherheitsabfrage */
if ( !class_exists('Toolbox') ) {
die();
}
/* Ab hier kann's los gehen */
add_filter('the_content', 'adds_block');
function adds_block($content){
if (is_single())
global $post;
$thePostID = $post->ID; // getting the post ID
$new_insert = '<span id="more-' .$thePostID.'"></span>' ;
return str_replace($new_insert, my_ad(), $content);
}
/* Anpassen an eigene Bed&uuml;rfnisse */
function my_ad(){
return '</p><div class="single-google-ad">'.do_shortcode('[adrotate group="6"]').'</div><p>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment