Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #4022
    Andrew Two
    Participant

    I am using the following code to exclude the featured image from displaying:
    <?php echo do_shortcode('[gallery itemtag="yoma" order="ASC" exclude="' . get_post_thumbnail_id( $post->ID ) . '"]'); ?>

    I use this to create a gallery on my page without there having to be any images coded into the content but I noticed today that the only description or title that appears is from the featured image. In the coding the titles and descriptions are blank and it has display:none as if there’s no data for them, so I’m hoping this can be resolved with a better shortcode?

    Any help would be appreciated – Thank you.

    #4023
    Bartosz
    Keymaster

    Can we take a look at the live site?

    #4024
    Andrew Two
    Participant

    http://goo.gl/IocqzB – The gallery is displayed under the description and large pink download link.

    #4025
    Andrew Two
    Participant

    I got titles or descriptions to show (above the image but not below) above using the “Pretty Photo” Lightbox Script setting but the rest of them are still blank. I made sure all these items in the gallery had titles/descriptions filled out: http://goo.gl/4V6Qvg

    I edited the script setting again and made it “FancyBox”, the html on the live page goes blank for all except Featured:
    <div id="fancybox-title" class="" style="display: none;"></div>

    #4026
    Bartosz
    Keymaster

    Each lightbox script works a bit differently when it comes to image captions (titles). But the always working solution is to apply the title atribute to image links (not images itself).

    The other thing is that WP native galleries do not add title attribute automatically. However you can modify that using wp_get_attachment_link filter.

    Here you can find some examples on how to use it to modify the gallery output: http://wordpress.org/support/topic/add-the-title-of-an-image-to-the-image-link-in-gallery

    #4045
    Andrew Two
    Participant

    Great – thank you, this code added in Functions solves everything. (just incase anyone has the same problem).

    function add_title_attachment_link($link, $id = null) {
    	$id = intval( $id );
    	$_post = get_post( $id );
    	$post_title = esc_attr( $_post->post_title );
    	return str_replace('<a href', '<a title="'. $post_title .'" href', $link);
    }
    add_filter('wp_get_attachment_link', 'add_title_attachment_link', 10, 2);
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.