Wordpress图像描述链接


Wordpress image description link

我修改了显示图像描述的代码:

function the_post_thumbnail_caption() {
  global $post;
  $thumbnail_id    = get_post_thumbnail_id($post->ID);
  $thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment'));
  if ($thumbnail_image && isset($thumbnail_image[0])) {
  echo '<p>'.$thumbnail_image[0]->post_content.'</p>';
  }
}

我需要的是如何在点击后在弹出窗口上显示图像的描述。我错过了什么?任何帮助都将不胜感激!谢谢

文件如下:

<?php get_header(); ?>
    <div id="primary">
    <!--    <div id="content" role="main"> -->
        <!--</div><!-- #content -->
        <?php if($_SERVER['REQUEST_URI'] == '/wordpress/?page_id=5'): ?>
            <!--<div style="float:right">-->
            <div style="width:640px; float:left;min-height:290px;word-wrap: break-word">
                <?php
                    $myposts = get_posts('');
                    foreach($myposts as $post) :
                        setup_postdata($post);
                ?>
                <div class="post-item">
                    <div class="post-info">
                        <h2 class="post-title">
                            <!--<a href="<?php //the_permalink() ?>" title="<?php //the_title_attribute(); ?>"><?php //the_title(); ?></a>-->
                            <b><?php the_title(); ?></b>
                        </h2>
                        <!--<p class="post-meta">Posted by <?php the_author(); ?></p>-->
                    </div>
                <div class="post-content">
                    <?php the_content(); ?>
                    <div style="margin:25px 0px;border:1px dotted #ccc; width: 640px;"></div>
                </div>
                </div>
                <?php //comments_template(); ?>
                <?php endforeach; wp_reset_postdata(); ?>
            </div>
            <div style="float:left; width:319px; min-height:200px; border-left:1px solid #ccc">
                <div style="float:left; margin-left:5px">
                    <h2 style="font-family:Mybold; font-size:14pt">Categories</h2>
                    <?php
                    the_post_thumbnail_caption();
                    $categories = get_categories();
                    foreach ($categories as $cat) {
                       $category_link = get_category_link($cat->cat_ID);
                       ?><p><a href="<?php echo esc_url( $category_link ); ?>" title="Category Name"><?php if($cat->parent < 1) echo $cat->cat_name; //echo $cat->category_nicename; ?></a></p><?php ; 
                    }
                    ?>
                </div>
            </div>
        <?php endif;?>
    </div><!-- #primary --> 
<?php get_footer(); ?>

快速思考-看看https://github.com/mikezahno/jPicDetail-一个用于在图像上覆盖文本的jQuery插件。该页面上还有一个jsFiddle演示链接。

我能想到如何解决这个问题的唯一方法是:添加你的图像A TITLE,然后你就可以像这样的东西:
Fiddle here

$('img').click(function(){
 var getTitle = $(this).attr('title');
 alert(getTitle);
 });

当然,您必须将jquery包含到您的页面中,请参阅Wordpress codex如何做到这一点。