Php Wordpress图像描述链接

Php Wordpress图像描述链接,php,javascript,jquery,wordpress,Php,Javascript,Jquery,Wordpress,我修改了显示图像描述的代码: 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 &

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

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>';
  }
}
function\u post\u缩略图\u标题(){
全球$员额;
$thumbnail\u id=get\u post\u thumbnail\u id($post->id);
$thumbnail\u image=get\u posts(数组('p'=>$thumnail\u id,'post\u type'=>'attachment');
if($thumbnail\u image&&isset($thumnail\u image[0])){
回显“”.$thumbnail\u image[0]->发布内容。“

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

文件如下所示:

<?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(); ?>

类别


快速思考-看一看-一个用于在图像上叠加文本的jQuery插件。
该页面上也有一个JSFIDLE演示链接。

我能想到的唯一解决办法是:给你的图片添加一个标题,然后你就可以了 大概是这样的:


当然,您必须在页面中包含jquery,看看如何做到这一点

我是wordpress的新手。谢谢你的插件。但是我怎样才能显示被点击的图像的描述呢?这个jQuery插件的要点是,你不必点击——你只需将鼠标移到上面,描述就会显示出来。谢谢你的插件。但我仍然有同样的问题。你能发布包含图像的每个段落的最终html吗?我刚刚发布了文件。这是你的原始PHP+html-我真的在寻找最终html-即html在浏览器中的外观。这是它的屏幕截图。例如,我点击了图片,会出现一个弹出窗口,显示图片的描述。因为你有很多重复的问题,比如:Wordpress图片描述,Wordpress图片帖子链接Wordpress图片描述弹出窗口,我建议删除它们(因为你已经注意到它会让人生气…)。相信我,我从Stack Owerflow开始时也犯了同样的错误。祝你一切顺利Dejo Dekic 2分钟前
$('img').click(function(){
 var getTitle = $(this).attr('title');
 alert(getTitle);

 });