Hot answers tagged

4

WordPress uses min( intval($content_width), $max_width ) inside image_constrain_size_for_editor for large image size. As I can see your $content_width is set to 660. So, change the $content_width in your functions.php file to the 1024 or whatever you need. For full-width layout, it's better to remove it. Example: $GLOBALS['content_width'] = 1600. That's ...


3

I have updated your code so that the fallback image has post permalink. I hope this helps: if ( has_post_thumbnail() ) { echo '<a href="' . get_permalink($post->ID) . '" >'; the_post_thumbnail(); echo '</a>'; } else { echo '<a href="' . get_permalink($post->ID) . '" ><img src="'. get_stylesheet_directory_uri() . ...


2

You are correct, you will need to get the image URL and set is as a variable so you can echo it out as an inline style in your HTML. I've updated your foreach loop below and set the image as an inline style of your <li> element: foreach( $postQuery as $post ) : setup_postdata($post); if ( has_post_thumbnail() ) { ?> /* Get the post ...


2

I think the problem may be that the_post_thumbnail() doesn't accept an ID as a parameter. Instead you should use get_the_post_thumbnail() which does accept an ID as a parameter: <?php echo get_the_post_thumbnail($authors_post->ID); ?>


1

It's because those GIF images exceeds the max-size supported by Facebook open graph ( 8Mb ). Check the debugger for Open Graph here For instance for post vbnvnvb , debugger show this error


1

With this code in header.php and some tweaks I fix it and I disable social yoast and activating another plugin open graph which let me choose what tags I want. <?php global $post; $src = wp_get_attachment_image_src( get_post_thumbnail_id( $post -> ID ) , 'thumbnail' ); if(strlen($src[0])){ echo '<meta ...


1

The problem is when you are trying to get the template directory. You are getting it instead of printing bloginfo() prints the output get_bloginfo() retrieves the output So, the nice piece of code should look like this: <?php if ( has_post_thumbnail() ) { echo '<a href="' . get_permalink($post->ID) . '" >'; the_post_thumbnail(); ...


1

There's a couple things that you need to do to get the URL - you could combine them into one long sentence probably but I'll break it down. WordPress stores the thumbnail ID in the postmeta table as _thumbnail_id so we need to get that using get_post_meta(): $thumb_id = get_post_meta( $post->ID, '_thumbnail_id', true ); Now that we have the ID we need ...


1

You'll have to code the output in the manner you want to display it. However you'll have to generate the image link prior to the html part. Save the image in a variable $bgimage1; make the list using li and in the list item backgroun-image: <?php echo $bgimage1; ?>



Only top voted, non community-wiki answers of a minimum length are eligible