WordPress.org

Ready to get started?Download WordPress

Forums

Display thumbnails as first image (2 posts)

  1. Hichamitooo
    Member
    Posted 1 year ago #

    Hi everyone,

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

    Thanks

  2. Hichamitooo
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic