• Resolved acruickshank

    (@acruickshank)


    Hi, My homepage shows my recent posts with short text extract. I would really like to add the first image of my post also. This previously happened when I entered the more buton in the appropriate place. Can you help me with this please.
    Alistair

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Ask the theme provider for help and guidance on this…

    https://weavertheme.com/

    It’s probably just a step to include a featured image but since it’s in the excerpt part of a page you might need to tweak the excerpt or edit the excerpt manually.

    For that, the theme author may have a better, quicker solution.

    Thread Starter acruickshank

    (@acruickshank)

    Thanks Jnash, The theme provider never responds.

    if the theme uses the WordPress function the_excerpt() and cooperates with its formatting, this might work with some code, added into functions.php (of a child theme):

    //add the first image of the post content before the excerpt//
    function excerpt_with_first_image( $html ) {
    	 global $post, $posts;
    	 $first_img = '';
    	 $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
    	 if( isset( $matches[1] [0] ) )  {
    	  	 $first_img_src = $matches [1] [0];
    		 $first_img_html = '<img class="alignleft" src="' . $first_img_src . '" alt="" />'; 
    		 $html = $first_img_html . $html; 
    	}
    	return $html;
    }
    add_filter( 'the_excerpt', 'excerpt_with_first_image' );

    code partially based on https://wordpress.stackexchange.com/questions/60245/get-the-first-image-from-post-content-eg-hotlinked-images

    Thread Starter acruickshank

    (@acruickshank)

    Thanks for the code Michael but I am pretty sure weaver overrides WP. Unfortunately any attempt I make at sending them a support question is met with an oops something went wrong, perhaps you need the paid version to get support. I would try another theme but I have spent so long getting my settings just right that I am reluctant to do so.
    Alistair

    Thread Starter acruickshank

    (@acruickshank)

    I just found that adding a featured image does the job on the homepage. Only thing is it also adds it to the post in a ridiculous position. Any way I can prevent the featured image from appearing on the homepage.
    Alistair

    Thread Starter acruickshank

    (@acruickshank)

    Thanks for trying to help

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘display images on homepage’ is closed to new replies.