Featured image: Dynamic image sizes when enlarged with javascript
Featured image: Dynamic image sizes when enlarged with javascript
Featured image: Dynamic image sizes when enlarged with javascript
To display featured image of a specific page/post in anywhere: $the_id = 4; // The Page or post ID echo wp_get_attachment_url( get_post_thumbnail_id($the_id, ‘thumbnail’) ); hope it will work, if not work try this: $args = array(‘page_id => 4’); $featured_image = get_posts($args); foreach($featured_image as $image) : setup_postdata($image); echo the_post_thumbnail(); endforeach; wp_reset_postdata();
Usage of add_image_size (for featured image)
It seems you have used a lot of posts & category. So, Once you update/add the post then recursion will occur. So, I suggest you should use a cache plugin. Try to put ini_set( ‘memory_limit’, ‘512M’); in wp-config header file & check it.
You can edit css? img{ display: block; width: 100%; height: auto; max-width: 100%; }
You can replace : <?php echo get_the_post_thumbnail( $post->ID, ‘full’ ); ?> with this: <?php echo get_the_post_thumbnail( $post->ID, ‘full’ , array( ‘alt’ => get_the_title() ) ); ?> to set the post tile as the alt attribute for the image
Updated answer below <?php define(‘WP_USE_THEMES’, false); require(‘blog/wp-blog-header.php’); ?> <div class=”row row-60 row-sm”> <?php $args = array( ‘numberposts’ => 3, ‘post_status’=>”publish”,’post_type’=>”post”,’orderby’=>”post_date”); $postslist = get_posts( $args ); foreach ($postslist as $post) : setup_postdata($post);?> <div class=”col-sm-6 col-lg-4 wow fadeInLeft”> <!– Post Modern–> <article class=”post post-modern”><a class=”post-modern-figure” href=”https://wordpress.stackexchange.com/questions/316782/<?php the_permalink( $post->ID ); ?>” target=”_top”> <?php echo get_the_post_thumbnail( $post->ID ); ?> … Read more
please use this code <?php $backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), ‘full’ );?> <div class=”header-wrap” style=”background: url(‘<?php echo $backgroundImg[0]; ?>’) no-repeat;”> <header class=”entry-header”> <h1 class=”entry-title”> <?php the_title(); ?> </h1> </header>
Missing image size
the_post_thumbnail displays the post thumbnail. It generates HTML tag and echoes it. It does not echo only the URL to that image. So this line: <img src=”https://wordpress.stackexchange.com/questions/324413/<?php the_post_thumbnail(); ?>” alt=”<?php the_post_thumbnail_caption() ?>”/> Generates something like this: <img src=”https://wordpress.stackexchange.com/questions/324413/<img src=”” … />” alt=”…”/> So it’s not a correct HTML. I’d changed it to: <div class=”col-12 col-sm-4″> … Read more