Choose to Display Post Thumbnail?

This is modified code from twentyten that does what you’re looking for. Put this in header or wherever you want the image to run. See string post-thumbnail — that is size. Make sure it is defined as 940 x 180 in functions.php if ( is_singular() && current_theme_supports( ‘post-thumbnails’ ) && has_post_thumbnail( $post->ID ) && ($image … Read more

Show posts image attachments

See the below code. <?php $args = array( ‘posts_per_page’ => -1, ‘order’=> ‘DESC’, ‘orderby’ => ‘date’ ); $postslist = get_posts( $args ); foreach ( $postslist as $post ) : setup_postdata( $post ); ?> <div> <?php $args = array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => -1, ‘post_status’ =>’any’, ‘post_parent’ => $post->ID ); $attachments = get_posts( $args ); … Read more

Problem with showing featured image

Use an is_single() condition to ensure the thumbnail isn’t added on archive pages. You should also be using get_the_post_thumbnail and prepending it to $content, rather than just echo’ing it out: function put_thumbnail_in_posting( $content ) { if ( is_single() && has_post_thumbnail() && get_post_type() == ‘post’ ) { $thumbnail = get_the_post_thumbnail( null, ”, array( ‘style’ => implode( … Read more

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)