show featured image to the beginning of each post if added any or show default post image

<?php

function easy_the_content_filter( $content ) {

        // Add image to the beginning of each post. if any featured image is added by  author than show the  featured  image otherwise  show  the  common image for all post  if no featured image is set by author.
       if ( is_singular(‘post’) && has_post_thumbnail()) {
        $thumbnail = get_the_post_thumbnail();

        $content = $thumbnail . $content;
       
        }
        else
        {
            $content = sprintf(‘<img class=”post-icon” src=”%s/images/php.jpg” alt=”Post icon” title=”” width=”100″/>%s’,get_bloginfo( ‘stylesheet_directory’ ),$content );
        }

    // Returns the content.
    return $content;
}

?>

Related Post

Leave a Reply