Add rel to all images in a post

something like this can be useful: function image_tag($html, $id, $alt, $title) { return preg_replace(array( “https://wordpress.stackexchange.com/”.str_replace(‘//’,’//’,get_bloginfo(‘url’)).’/i’, ‘/s+width=”d+”/i’, ‘/s+height=”d+”/i’, ‘/alt=””/i’ ), array( ”, ”, ”, ‘alt=”‘ . $title . ‘”‘ ), $html); } add_filter(‘get_image_tag’, ‘image_tag’, 0, 4);

has_post_thumbnail() Returns False on Scheduled Posts

Well it turns out that the reason has_post_thumbnail() was failing was because get_post_meta() was returning empty for scheduled posts. I’m still not sure why, but in case someone else has the issue, my workaround was to create a new function to fetch the featured image ID without relying on get_post_meta(): function get_featured_image_id($postID) { global $wpdb; … Read more

Display image title and caption inside a single post

I got a few minutes and made the custom code for you. Copy and paste this in your themes functions.php remove_shortcode(‘gallery’, ‘gallery_shortcode’); add_shortcode(‘gallery’, ‘gallery_shortcode_custom’); function gallery_shortcode_custom( $attr ) { $post = get_post(); static $instance = 0; $instance++; if ( ! empty( $attr[‘ids’] ) ) { // ‘ids’ is explicitly ordered, unless you specify otherwise. if … Read more

Featured Image not changing

Sorry you’re having trouble with the featured image. Some details that will help the community solve the question: What theme are you using? Without knowing what theme you’re using, one approach you might try is removing the featured image from the post/page, then click update. If the featured image is removed, you might then be … Read more

Get attachment if matches a variable

$attachments holds array of posts, you are missing something like: $attachment = $attachments[0]; or foreach( $attachments as $attachment ) Update Nope, like this: foreach( $attachments as $attachment ) if ($attachment->post_title == $programme) { echo the_attachment_link($post->ID, false); break; }

Change the avatar ratio?

Possible sollutions: Use Css with something like overflow: hidden; and “cut out” what you need. Use the filter apply_filters(‘get_avatar’, $avatar, $id_or_email, $size, $default, $alt); and override the output of $avatar completely. The function get_avatar() is pluggable. That means if you hook a plugin function early enough that already defines get_avatar() then this function will be … Read more