Distinguish between page and post in function

Question

I’m trying to apply some text to the “Featured Image” box. It works fine for a custom post type, but I can’t get a specific piece of text appearing on pages rather than posts.

add_filter( 'admin_post_thumbnail_html', 'foo' );
function foo( $content ) {
    global $post_type;
    if ( $post_type = 'page') {
        $content = '<p>foobar</p>' . $content;
     }
    else{
        $content = '<p>barfoo</p>' . $content;
     }
     return $content;
}

How can I get WordPress to identify if it is just a page?

0
, , JohnG 3 years 2019-10-21T08:12:51-05:00 0 Answers 80 views 0

Leave an answer

Browse
Browse