我怎样才能让我的wordpress.org网站上的整个图像点击? [英] How can I make the entire image clickable on my wordpress.org site?
本文介绍了我怎样才能让我的wordpress.org网站上的整个图像点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现在我的帖子只能通过点击标题点击,但我很想将整个图片链接到每个帖子。
< article id =post-<?php the_ID();?> <?php post_class('card-box col-lg-4 col-md-6 col-sm-12 col-xs-12'); ?>>
< div class =carddata-background =imagedata-src =<?php esc_url(the_post_thumbnail_url('large'));?>>
< div class =header>
<?php
$ categories = get_the_category();
if(!empty($ categories)){
?>
< div class =category>
< h6>
< span class =category>
<?php echo'< a class =categoryhref ='。esc_url(get_category_link($ categories [0] - > term_id))。'>'。 esc_html($ categories [0] - >名称)。 < / A>; ?>
< / span>
< / h6>
< / div>
<?php}?>
< / div>
< div class =content>
<?php the_title('< h4 class =entry-title>< a href ='。esc_url(get_permalink())。' =bookmark>', < / a>< / h4>'); ?>
< span class =date><?php echo esc_html(get_the_date()); ?>< /跨度>
< / div>
< div class =filter>< / div>
< / div> <! - 结束卡 - >
< / article>
我不想使用js,因为我被告知这不是SEO友好的。 p>
我已经试过使用标题,并且使用相同链接围绕整个div,但它没有用。
< / p> a href =...>
< img alt =...src =.../>
< / a>
Right now my posts can only be clicked by clicking the title, but I would love for the entire image to link to each individual post.
<article id="post-<?php the_ID(); ?>" <?php post_class('card-box col-lg-4 col-md-6 col-sm-12 col-xs-12'); ?>>
<div class="card" data-background="image" data-src="<?php esc_url( the_post_thumbnail_url( 'large' ) ); ?>">
<div class="header">
<?php
$categories = get_the_category();
if ( ! empty( $categories ) ) {
?>
<div class="category">
<h6>
<span class="category">
<?php echo '<a class="category" href="' . esc_url( get_category_link( $categories[0]->term_id ) ) . '">' . esc_html( $categories[0]->name ) . '</a>'; ?>
</span>
</h6>
</div>
<?php } ?>
</div>
<div class="content">
<?php the_title( '<h4 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h4>' ); ?>
<span class="date"><?php echo esc_html( get_the_date() ); ?></span>
</div>
<div class="filter"></div>
</div> <!-- end card -->
</article>
I don't want to use js because I've been told that's not SEO friendly.
I've tried using the tag from the entry-title and surrounding the whole div with that same link, but it did not work.
解决方案
That's how it is done in HTML:
<a href="...">
<img alt="..." src="..." />
</a>
这篇关于我怎样才能让我的wordpress.org网站上的整个图像点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文