Change Output for Images in Content

One way is to do this dynamically: function do_the_replacements($matches){ // $matches[0] = full string // $matches[1] = link attributes // $matches[2] = link contentes (the image) // change ‘someclass’ here… if(strpos($matches[2], ‘someclass’) !== false){ return ‘ <div class=”featured-img”> <a ‘.$matches[1].’>’.$matches[2].'</a> <div class=”corner-nw”></div> <div class=”corner-ne”></div> <div class=”corner-sw”></div> <div class=”corner-se”></div> </div> ‘; } // no matches, leave … Read more

How to get_posts having post thumbnail?

The thumbnail is stored as a meta with a key of _thumbnail_id, so that could be used to find posts that have thumbnails. Something like this: $query = new WP_Query(array( ‘meta_query’ => array( array( ‘key’ => ‘_thumbnail_id’, ‘value’ => ‘0’, ‘compare’ => ‘>=’, ) ) ));

can the_excerpt function also get images?

Ensure that your Theme supports Post Thumbnails, and that the client sets a “Featured Image” for each post. Then, combine the_excerpt() with the_post_thumbnail(), e.g. like so: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>> <div class=”featured-image”><?php the_post_thumbnail(); ?></div> <div class=”post-excerpt”><?php the_excerpt(); ?></div> </div> … Read more

Implementing Zurb’s Interchange Into WordPress

If you haven’t already enabled thumbnails in your theme, add this snippit to your functions.php: add_theme_support(‘post-thumbnails’); Then add this code. add_image_size( ‘responsive-small’, 300, 500 ); add_image_size( ‘responsive-large’, 768, 500 ); Here’s how it works: function( ‘unique_identifier’, width, height); Now the fun part. To use this in your template: <?php if ( have_posts() ) : while … Read more

get_thumbnail_id returns full size image

Hey First add this line into your function.php file add_image_size( ‘custom-size’, 120, 140 ); Then call custom-size like this <?php $thumb_id = get_post_thumbnail_id( $id ); if ( ” != $thumb_id ) { $thumb_url = wp_get_attachment_image_src( $thumb_id, ‘custom-size’, true ); $image = $thumb_url[0]; }?> <img src=”https://wordpress.stackexchange.com/questions/172703/<?php echo $image;?>”> I think it work fine

Set post-thumbnail (with php)?

The issue is going to be the difference in the data required for setting the post thumbnail (an attachment ID) and what’s probably in the custom field: a URL. The way I’m going to suggest is very sloppy: adds more attachments to WordPress. A better way might be to write a custom SQL query where … Read more

How to show featured image CAPTION only if it exist

I am a “little late” but this solution worked great for me. It will show the div only if the caption is not empty. <?php $get_description = get_post(get_post_thumbnail_id())->post_excerpt; the_post_thumbnail(); if(!empty($get_description)){//If description is not empty show the div echo ‘<div class=”featured_caption”>’ . $get_description . ‘</div>’; } ?>

Set post thumbnail as background

The problem here is the_post_thumbnail() doesn’t return image url but the img tag. You can use this code $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); echo ‘<li class=”produkt” style=”background: url(‘. $url.’)”>’;

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