How do I add a default thumbnail to elseif when no get_field(‘photos’), and no post thumbnail exists?

The function you are looking for is has_post_thumbnail() With this function you can check, if a featured image has been attached to a post and perform the following code: <?php if( get_field( ‘photos’ ) ): ?> <div class=”img”> <?php echo ‘<a class=”image” href=”‘ . get_permalink() . ‘”><div class=”img”><img src=”‘ . $model_pic[0][‘sizes’][‘models’] . ‘” /></div><div class=”info”><h3>’ … Read more

Retrieving featured image on static blog posts page

In your example, $posts_page contains the ID of the page for posts, you can use that with any API function that accepts a post ID. For the featured image: $posts_page = get_option( ‘page_for_posts’ ); $post_thumbnail_id = get_post_thumbnail_id( $posts_page ); $url = wp_get_attachment_image_src( $post_thumbnail_id, ‘your-custom-size’ ); echo $url; And outputting post title with filters applied: $posts_page … Read more

Get Featured Image Outside Loop Not Working

First you have to make sure the current post ID + 1 and Current post ID – 1 is exactly the post ID of the next and previous posts. if it is correct then you can use <img src=”https://wordpress.stackexchange.com/questions/244237/<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id($prevID),”full’); echo $image[0];?>” /> and <img src=”https://wordpress.stackexchange.com/questions/244237/<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id($nextID),”full’); echo $image[0];?>” … Read more

the_title() is not displaying over the_thumbnail

the_post_thumbnail() and get_the_post_thumbnail() will output the complete HTML for displaying that image. So this <img class=”img-responsive” src=”https://wordpress.stackexchange.com/questions/274181/<?php the_post_thumbnail(); ?>” alt=””> will be rendered to something like this <img class=”img-responsive” src=”https://wordpress.stackexchange.com/questions/274181/<img src=”…” alt=”..” class=”..”>” alt=””> which is not valid HTML and you can’t really tell how browsers will display this. Now you have 2 choices: Use … Read more