html - 如何使整个图像在我的 wordpress.org 网站上可点击?

标签 html css wordpress

现在我的帖子只能通过点击标题来点击,但我希望整个图片都链接到每个单独的帖子。

<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>

我不想使用 js,因为有人告诉我这对 SEO 不友好。

我试过使用 entry-title 中的标签并用相同的链接包围整个 div,但它没有用。

最佳答案

这就是 HTML 中的做法:

<a href="...">
    <img alt="..." src="..." />
</a>

关于html - 如何使整个图像在我的 wordpress.org 网站上可点击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43058846/

相关文章:

wordpress - Woocommerce 商店经理角色,隐藏 woocommerce 菜单

javascript - jQuery:动画 slider 寻呼机

html - 窗口仍然有水平滚动

html - CSS 选择器定位没有任何属性的标题

css - Bootstrap 4 垂直对齐不起作用

jquery - 调整html中文本的大小属性

jquery - 在 wordpress 中使图像响应?

javascript - fancybox 弹出窗口中的链接

html - 在表格单元格中,如何设置背景颜色并将内容放在中间?

css - 为什么我的 div 背景图片消失了?