Please disable your Ad Blocker to better interact with this website.

BLOG

See what we're whipping up!

function wpdev_before_after($content) {
    if(is_page() || is_single()) {
    
        // Date Variables
        $startdate = '20170102'; // Format YEAR/MONTH/DAY
        $enddate = '20170516'; // Format YEAR/MONTH/DAY
        $currentdate = date('Ymd'); // Format YEAR/MONTH/DAY
        $past60days = strtotime('-60 days');
        $postdate = get_the_date('Ymd', get_the_id());
    
        // If you want to display before and after content for a specific time period
        if($currentdate > $startdate && $currentdate < $enddate) {
            $beforecontent = 'This goes before the content. Isn\'t that awesome!';
            $aftercontent = 'This could be an email sign-up form at the end of the content.';
        } else {
            $beforecontent = ''; // Don't display anything anymore.
            $aftercontent = ''; // Don't display anything anymore.
        }
        
        // If you want to display before and after content on posts from a specific time period
        if($postdate > $startdate && $postdate < $enddate) {
            $beforecontent = 'This goes before the content. Isn\'t that awesome!';
            $aftercontent = 'This could be an email sign-up form at the end of the content.';
        } else {
            $beforecontent = ''; // Don't display anything anymore.
            $aftercontent = ''; // Don't display anything anymore.
        }
        
        // If you want to display before and after content on posts published from 60 days ago until now
        if($postdate > $past60days) {
            $beforecontent = 'This goes before the content. Isn\'t that awesome!';
            $aftercontent = 'This could be an email sign-up form at the end of the content.';
        } else {
            $beforecontent = ''; // Don't display anything anymore.
            $aftercontent = ''; // Don't display anything anymore.
        }
        
        // Output
        $fullcontent = $beforecontent . $content . $aftercontent;
        
    } else {
        $fullcontent = $content;
    }
    
    return $fullcontent;
}
add_filter('the_content', 'wpdev_before_after');

No comments yet