WordPress.org

Ready to get started?Download WordPress

Forums

[WP-ECARDS] Add code to plugin so it shows image captions? (5 posts)

  1. xiabolai
    Member
    Posted 3 years ago #

    Hi,

    I'm using the WP-ECARDS plugin. The plugin uses a shortcode and the built-in WordPress Media Manager to upload the images to be used as ecards. My problem is, that the ecard gallery created by the plugin and shortcode DOES NOT display image captions. I've tried adding a caption when uploading an ecard image, but still nothing shows up. That means the plugin code is not "pulling in" the caption.

    I'm a bit of a newbie...can anyone tell me what code to use and where I'd place it so that each ecard thumbnail shows an associated caption below it? Here's the plugin code that displays the ecard thumbnail gallery:

    <ul id="ft_wpecards_image_select_list">
    					<?php
    					if ( $images = $this->get_images() ) {
    						//print_r($images);die();
    						foreach ( $images as $key => $value ){
    							?><li class="ft_wpecards_image_select_item"><a href="<?php echo wp_get_attachment_url($value->ID);?>" class='thickbox' rel="<?php echo 'wp_ecard_'.$post->ID;?>"><?php echo wp_get_attachment_image($value->ID, array(75,75), false); ?></a><span><input type="radio" name="ft_wpecards_image" value="<?php echo $value->ID; ?>" <?php $this->is_image_selected( $value->ID ); ?>/></span></li><?php
    						}
    					}else{
    						?><li class="ft_wpecards_image_select_error">No images exist for this page.</li><?php
    					}
    					?>
    				</ul>

    Any help would be deeply appreciated.

    Thanks!

  2. xiabolai
    Member
    Posted 3 years ago #

    follow up...i found the following code. thought it was the solution to pulling in the caption, but every time i insert it, it breaks the page. can anyone point me in the right direction?

    <div class="postthumb"><?php echo the_post_thumbnail('medium') ;?><br><?php echo $attachment->post_excerpt ?></div>
                            <?php } ?>

    much appreciated.

  3. xiabolai
    Member
    Posted 3 years ago #

    bump...anyone? i feel like i'm so close...

  4. xiabolai
    Member
    Posted 3 years ago #

    i also found this code, which should work...

    <div class="caption">
    <?php if ( !empty($post->post_excerpt) ) the_excerpt(); // this is the "caption" ?>
    </div>

    but if i place it after this...

    <?php echo wp_get_attachment_image($value->ID, array(75,75), false); ?>

    ...still no caption shows up. arrgghh! what am i doing wrong?

  5. inspirationally
    Member
    Posted 3 years ago #

    any solution on this already?

    //EDIT: got it

    in the class_ftwpecards.php

    find

    foreach ( $images as $key => $value ){

    add below

    $relatedpost = $value->ID;
    $imagepost = get_post($relatedpost);
    $caption = $imagepost->post_excerpt;

    and somewhere before the <span><input type="radio"...

    add <?php echo $caption; ?>

    and customize it to your needs.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags