Style wordpress image captions in RSS

As far as I know the only way to add styles to RSS feed items is by adding them inline (e.g. <p style=”color: #333; font-weight: bold;”>Hello World</p>). If you don’t specify any styling, then the reader app/website that the end-user is using applies its default styles. Certainly editing styles.css won’t make any difference, because that … Read more

Display a post attachment depending on the caption

Can you try something along these lines and report back the result? <?php if(qtrans_getLanguage()==’en’): ?> // attachment if statement <?php else if(qtrans_getLanguage()==’fr’): ?> // attachment if statement <?php endif; ?> Technically you could omit the second else if statement and replace it just with <?php else : ?> assuming you only have two languages you … Read more

Remove wp-caption but still show the image

You’ll need to use the img_caption_shortcode filter to do this. Pretty certain the alignment of the image (floating left/right) is part of the caption so you’ll lose the ability to do that with this code. function imageOnly($deprecated, $attr, $content = null) { return do_shortcode( $content ); } add_filter( ‘img_caption_shortcode’, ‘imageOnly’, 10, 3 ); The do_shortcode … Read more

Random home page background images with caption text

First of all I don’t think that create a custom post type only for backgrounds is a right choose: backgrond are images and images already have their post type: attachment. If you have Worpress 3.5+ you can register a custom taxonomy for attachments, call it, e.g. ‘image_scope’ : register_taxonomy(‘image_scope’, ‘attachment’, $args ); for the $args … Read more

Custom caption output for custom image size

You need only a regex to catch the class from content, check if the class for you size is one of the assigned class and if so add to output, something like: function my_custom_img_caption_shortcode($a, $attr, $content = null) { extract( shortcode_atts( array( ‘id’ => ”, ‘align’ => ‘alignnone’, ‘width’ => ”, ‘caption’ => ” ), … Read more

How to get the_post_thumbnail caption?

Use the shortcode handler img_caption_shortcode to render the HTML for you, though you do need to pass it a width (which we can easily get with wp_get_attachement_image_src: function wpse_138126_thumbnail_caption( $html, $post_id, $post_thumbnail_id, $size, $attr ) { if ( $post = get_post( $post_thumbnail_id ) ) { if ( $size = wp_get_attachment_image_src( $post->ID, $size ) ) $width … Read more