Skip to content

Instantly share code, notes, and snippets.

@Santel
Santel / functions.php
Created January 16, 2014 08:29
Remove first image in the posts that published before 2014
//* Remove first image from posts that published before 2014
function remove_first_image ($content) {
if (!is_page() && !is_feed() && !is_home()&& get_the_date('Y')<2014) {
$content = preg_replace("/<img[^>]+\>/i", "", $content, 1);
} return $content;
}
add_filter('the_content', 'remove_first_image');
@Santel
Santel / functions.php
Last active January 16, 2021 16:49
Remove first image from WordPress post
//* Remove first image from single post
function remove_first_image ($content) {
if (!is_page() && !is_feed() && !is_home()){
$content = preg_replace("/<img[^>]+\>/i", "", $content, 1);
} return $content;
}
add_filter('the_content', 'remove_first_image');
.adsense_above_post {
text-align:center;
margin:30px auto;
}
.adsense_before_footer {
clear: both;
text-align:center;
margin:30px auto;
}
<div class="adsense_above_post">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-xxx";
width = document.documentElement.clientWidth;
/* Display Mobile Ads */
google_ad_slot = "xxx";
google_ad_width = 320;
google_ad_height = 50;
/* Display 336x280 if screen bigger than 480px */
/** Add Adsense above post title */
add_action( 'genesis_before_post', 'adsense_above_post' );
function adsense_above_post() {
if (is_singular( 'post' )){
require(CHILD_DIR.'/adsense_above_post.php');
}
}
/** Add Adsense above footer */