add image caption
From quick look caption seems to be stored as excerpt (rather than part of data in meta array), so you should use wp_update_post() to add it.
From quick look caption seems to be stored as excerpt (rather than part of data in meta array), so you should use wp_update_post() to add it.
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
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
For your first question- HTML support for captions was a new feature in wordpress 3.4, if you have any version prior to that, it won’t work I’m not sure if i understood your 2nd question, but to exclude the caption from not displaying on the page, you’ll have to either delete the caption from the … Read more
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
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
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
It looks like your WP Jquery Lightbox plugin is generating these extra captions. Check out the source of the jquery.lightbox.js file: … cut … var s=””; if (title != ”) { s=”<span id=”titleText”>” + title + ‘</span>’; } if (caption != ”) { if (title != ”){ s += ‘<br />’; } s += ‘<span … Read more
Don’t know what was the actual problem. Using following syntax to display content solved problem. <div> <h tag><?php the_title(); ?></h tag> ………….other things like date and author <div> <?php the_content(); ?> </div> </div> Any way, thanks for everybody who tried to answer my question.
To remove caption text, you can override the caption short-code using below code: add_filter( ‘img_caption_shortcode’, ‘my_img_caption_shortcode’, 10, 3 ); function my_img_caption_shortcode( $empty, $attr, $content ){ $attr = shortcode_atts( array( ‘id’ => ”, ‘align’ => ‘alignnone’, ‘width’ => ”, ‘caption’ => ” ), $attr ); if ( 1 > (int) $attr[‘width’] || empty( $attr[‘caption’] ) ) … Read more