How to display recent posts on home page with title, post date, author and featured image?

The functions you are looking for, are: the_post_thumbnail_url(); // For featured image the_author(); // For author name get_author_posts_url(); // For author link the_date(); // For post’s date So, your code should be something like this: <div class=”cs-post-carousel-layout”> <div class=”cs-container swiper-container”> <div class=”swiper-wrapper”><?php // define query arguments $args = array( ‘posts_per_page’ => 5, // your ‘x’ … Read more

Change background image in PHP

You won’t be able to delete the image per se, but using CSS you can hide the image. You should also make sure you fix the typo inside of your inline style it should read background-image: url(…). For the varying styles, you can utilize media queries to hide at a certain point. I don’t recommend … Read more

Convert thumbnail ID into image URL

There are two functions you can use for this: wp_get_attachment_url to get the full sized image or wp_get_attachment_thumb_url, which gets the url of the thumbnail of that attachment. Either function takes the attachment id as the sole argument: $attachment_id= 25; //Get the full url $url = wp_get_attachment_url( $attachment_id ); //get the thumbnail $thumb = wp_get_attachment_thumb_url( … Read more

Different thumbnail size than actual picture in post

This is quite simple to implement, using core post-thumbnails functionality. First, you need to add Theme support for the feature, via functions.php: <?php function wpse54920_setup_theme() { // Support post thumbnails add_theme_support( ‘post-thumbnails’ ); } add_action( ‘after_setup_theme’, ‘wpse54920_setup_theme’ ); ?> Next, you need to define your custom image sizes, using add_image_size(). Let’s say you want the … Read more

get_the_post_thumbnail() – Invalid argument supplied for foreach() in /wp-includes/post-thumbnail-template.php on line 64

This Trac ticket here describes your problem and the cause: https://core.trac.wordpress.org/ticket/26321 I got a warning/error related to update_post_thumbnail_cache() function: Warning: Invalid argument supplied for foreach() in ./wp-includes/post-thumbnail-template.php on line 64 The $wp_query->posts array is missing, but we have the single $wp_query->post. foreach ( $wp_query->posts as $post ) { if ( $id = get_post_thumbnail_id( $post->ID ) … Read more