0

Would like to add a caption to FlexSlider, which is integrated into a purchased Wordpress Organictheme. I believe the slideshow page code must be modified and though I have found some similar issues here, I have not figured out (after many hours and failed attempts) where and what exactly to add to the existing code. Seems like captions should be a no-brainer! Seems like they should somehow be included within the

  • tags??? Would REALLY APPRECIATE some help. html, but NOT php literate. THANK YOU!

    The code needs to go somewhere in here:

                <div class="flexslider">
    
                    <ul class="slides">
    
                        <?php $data = array(
                            'post_parent'       => $post->ID,
                            'post_type'         => 'attachment',
                            'post_mime_type'    => 'image',
                            'order'             => 'ASC',
                            'orderby'           => 'menu_order',
                            'numberposts'       => -1
                        ); ?>
    
                        <?php 
                        $images = get_posts($data); foreach( $images as $image ) { 
                            $imageurl = wp_get_attachment_url($image->ID);              echo '<li><img src="'.$imageurl.'"  /></li>' . "\n"; 
                        } ?>
    
                    </ul>
    
                </div>
    
    4

    1 回答 1

    0

    确实,你非常接近。

    我会回答这个以防其他人需要它。缺少的两个代码位是:

    <p class="flex-caption"><?php echo $caption; ?></p>
    

    ... flexslider 需要显示标题,以及

    $caption = $image->post_excerpt;
    

    ...实际获得字幕。新代码将是:

            <div class="flexslider">
    
                <ul class="slides">
    
                    <?php $data = array(
                        'post_parent'       => $post->ID,
                        'post_type'         => 'attachment',
                        'post_mime_type'    => 'image',
                        'order'             => 'ASC',
                        'orderby'           => 'menu_order',
                        'numberposts'       => -1
                    ); ?>
    
                    <?php 
                    $images = get_posts($data);
                    foreach( $images as $image ) { 
                        $imageurl = wp_get_attachment_url($image->ID);
                        $caption = $image->post_excerpt;
                        echo '<li><img src="'.$imageurl.'"  /><p class="flex-caption">'.$caption.'</p></li>' . "\n";
                    } ?>
    
                </ul>
    
            </div>
    
    于 2013-08-23T20:47:40.143 回答