• Resolved kristanlh

    (@kristanlh)


    I feel like this should be simple, but I can’t quite figure out the code.

    How can I add a parameter so that this plugin only applies to posts before a certain date?

    TIA!

Viewing 1 replies (of 1 total)
  • Thread Starter kristanlh

    (@kristanlh)

    Never mind, I figured it out!

    This is the modified code I needed (which also removed “is_singular() &&” from the if statement because I actually want this to apply to any view).

    add_filter( 'the_content', 'featured_image_in_content_add_to_content' );
    function featured_image_in_content_add_to_content( $content ) {
    	if ( has_post_thumbnail() && (get_the_date( 'Y' ) < 2018) ) {
    		return get_the_post_thumbnail( null, 'large' ) . $content;
    	} else {
    		return $content;
    	}
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Only apply to posts before a certain date?’ is closed to new replies.