Php 使整个div可单击到_permalink();
我有以下代码:Php 使整个div可单击到_permalink();,php,wordpress,hyperlink,Php,Wordpress,Hyperlink,我有以下代码: <div class="carousel-caption"> <div class="carousel-caption-inner"> <p class="carousel-caption-title" data-postid="<?php the_ID(); ?>" data-excerpt="<?php echo esc_html( get_the_excerpt() ); ?>" data-
<div class="carousel-caption">
<div class="carousel-caption-inner">
<p class="carousel-caption-title" data-postid="<?php the_ID(); ?>" data-excerpt="<?php echo esc_html( get_the_excerpt() ); ?>" data-published="<?php echo get_the_date(); ?>"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
<p class="carousel-caption-category"><?php echo get_the_category_list( ', ' ); ?></p>
</div>
</div>
可以将内部div包装在锚元素中,将其转换为链接,并删除当前包装标题的锚
这在HTML5中是有效的
<div class="carousel-caption">
<a href="<?php the_permalink(); ?>">
<div class="carousel-caption-inner">
<p class="carousel-caption-title" data-postid="<?php the_ID(); ?>" data-excerpt="<?php echo esc_html( get_the_excerpt() ); ?>" data-published="<?php echo get_the_date(); ?>">
<?php the_title(); ?>
</p>
<p class="carousel-caption-category"><?php echo get_the_category_list( ', ' ); ?></p>
</div>
</a>
</div>
我自己能修好它
我就是这样解决的。(我在某处发现了这个方法,不是我发明的:D)
它使我的白色区域变得可点击,并将我带到帖子链接
谢谢 它不起作用,因为类“carousel caption internal”上有css,这就是白框的创建方式。“.carousel-caption-inner{background:#fff;padding:30px 40px!important;}”未删除类carousel-caption-inner
<div class="carousel-caption">
<a href="<?php the_permalink(); ?>">
<div class="carousel-caption-inner">
<p class="carousel-caption-title" data-postid="<?php the_ID(); ?>" data-excerpt="<?php echo esc_html( get_the_excerpt() ); ?>" data-published="<?php echo get_the_date(); ?>">
<?php the_title(); ?>
</p>
<p class="carousel-caption-category"><?php echo get_the_category_list( ', ' ); ?></p>
</div>
</a>
</div>
<div class="carousel-caption container1">
<a href="<?php the_permalink(); ?>"><span class="link-spanner"></span></a>
<div class="carousel-caption-inner">
<p class="carousel-caption-title" data-postid="<?php the_ID(); ?>" data-excerpt="<?php echo esc_html( get_the_excerpt() ); ?>" data-published="<?php echo get_the_date(); ?>"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
<p class="carousel-caption-category"><?php echo get_the_category_list( ', ' ); ?></p>
</div>
</div>
<a href="<?php the_permalink(); ?>"><span class="link-spanner"></span></a>
.container1{
position:absolute;
}
.link-spanner {
position:absolute;
width:100%;
height:100%;
top:0;
left: 0;
z-index: 1;
}