BLOG

See what we're whipping up!

function wpdev_before_after($content) {
    if(is_page() || is_single()) {
        $rand1 = rand(0,1);
        $rand2 = rand(0,1);
        
        // If/Else for Before
        if($rand1 == 1) {
            $beforecontent = 'This goes before the content. Isn\'t that awesome!';
        } else {
            $beforecontent = 'Or this could go before the content, depending on whether or not a 0 or a 1 is generated.';
        }
        
        // If/Else for After
        if($rand2 == 1) {
            $aftercontent = 'This could be an email sign-up form at the end of the content.';
        } else {
            $aftercontent = 'Or it could be a Facebook like button.';
        }
        
        // Output
        $fullcontent = $beforecontent . $content . $aftercontent;
        
    } else {
        $fullcontent = $content;
    }
    
    return $fullcontent;
}
add_filter('the_content', 'wpdev_before_after');

No comments yet