get_the_post_thumbnail_url(‘full’) returns empty from custom post type

The first argument for that function is not size. See the documentation (if a function’s not working, checking the documentation should always be your first step): get_the_post_thumbnail_url( int|WP_Post $post = null, string|array $size=”post-thumbnail” ) The first argument is which post the get the URL for, while the size is the second argument. To avoid redundancy, … Read more

how to post default thumbnail if post not created yet

Create “images” folder in current active theme the put “https://wordpress.stackexchange.com/questions/332635/dummy-image-1-1.jpg” in that folder. <?php if ($the_query->have_posts() ) : while ($the_query->have_posts()) : $the_query->the_post(); if ( has_post_thumbnail( ) ) { the_post_thumbnail( ‘full’, array( ‘class’ => ‘mySlides’ ) ); } else { ?> <img src=”https://wordpress.stackexchange.com/questions/332635/<?php echo get_template_directory_uri().”/images/dummy-image-1-1.jpg’; ?>” class=”mySlides” height=”350px”/> <?php } endwhile; else: ?> <img src=”https://wordpress.stackexchange.com/questions/332635/<?php echo … Read more

Is there a best practice remediation for PhpStorm’s warning that void function the_post_thumbnail is used?

The solution is simple, don’t echo the result of that function, there is no result to echo. echo the_post_thumbnail(array(155,55)); Is equivalent to something like this: echo ”; the_post_thumbnail(array(155,55)); Functions that begin with the_ in WP don’t return things, they output things. Some of them let you pass a parameter that lets them return instead, but … Read more

How to deal with wordpress images?

Passing explicit dimensions to those APIs won’t give you an image with those dimensions unless one already exists. It will choose the image size that’s closest. So, you have 2 options Add a named image size via add_image_size that matches the desired dimensions. WordPress will generate an image of this size on upload. You will … Read more

query_posts adding two “post-entry” divs

Something like this?.. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div id=”post-<?php the_ID(); ?>”> <?php if ( has_post_thumbnail()) { ?> <div class=”post-thumb”> <?php the_post_thumbnail(); ?> </div> <div class=”post-entry-1″> <?php the_excerpt(); ?> </div> <? } else { ?> <div class=”post-entry-2″> <?php the_excerpt(); ?> </div> <?php } ?> </div> <?php endwhile; … Read more

Featured images, am I missing something?

As mentioned by @Michael in his answer the theme has to support the Post Thumbnail functionality. All you need to do for it is to put this line into the theme’s function.php file: add_theme_support( ‘post-thumbnails’ ); There’s a good chance it’s there already, so search first. Now you only need to output the image somehow. … Read more