WordPress.org

Support

Support » How-To and Troubleshooting » Display thumbnails as first image

Display thumbnails as first image

  • Hichamitooo
    Member

    @hichamitooo

    Hi everyone,

    Can someone show me how to display thumbnails as first image in the left corner of post content.

    Thanks

Viewing 1 replies (of 1 total)
  • Hichamitooo
    Member

    @hichamitooo

    I found this function but this add the featured image after a paragraph.
    how to make it add it in top left corner?

    add_filter('the_content', function($content)
    {
       $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
       $img = '<img src="'.$url.'" alt="" title=""/>';
       $content = preg_replace('#(<p>.*?</p>)#','$1'.$img, $content, 1);
       return $content;
    });

    help please

Viewing 1 replies (of 1 total)
  • The topic ‘Display thumbnails as first image’ is closed to new replies.