• I was learning how to make my own WordPress plugin, currently I’m confusion how if there is no thumbnail in the post then I use the default image as thumbnail. code that I use:

    add_action( 'the_post', 'mythumb' );
    function mythum(){
       if (!has_post_thumbnail()) {
        $defaultthum = "https://example.com/default.jpg"
        echo ('<div class="featured-thumbnail"><img width="150" height="150" src="'.$defaultthum.'" class="attachment-featured wp-post-image" alt="7" title="" /></div>')
       }
    }

    my problem: the default image thumbnail is not in the right position. see this picture: https://s22.postimg.org/ezt05f59d/Lm_XUp.png any idea? or the hooks is not the_post?
    Thanks

  • The topic ‘[HELP] WordPress Thumbnail add action if no thumbnail?’ is closed to new replies.