0

我刚开始以 Bones“框架”为主题,我想让首页文章预览链接到帖子,而不仅仅是<h1>链接。

我如何实现这一目标?使整个预览链接成为可点击的 div?

这是该部分的模型!:)

<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">

                            <header class="article-header">

                                <h1 class="h2"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>

                                <p class="byline vcard"><?php _e('Posted', 'bonestheme'); ?> <time class="updated" datetime="<?php echo the_time('Y-m-j'); ?>" pubdate><?php the_time(get_option('date_format')); ?></time> <?php _e('by', 'bonestheme'); ?> <span class="author"><?php the_author_posts_link(); ?></span> <span class="amp">&</span> <?php _e('filed under', 'bonestheme'); ?> <?php the_category(', '); ?>.</p>

                            </header> <!-- end article header -->

                            <section class="entry-content clearfix">
                                <?php the_content(); ?>
                            </section> <!-- end article section -->
4

2 回答 2

0

不确定它是否符合 HTML5 规范,但您可以尝试移动 以包装所有文章..:

    <article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">

<!-- move <a> to here -->

<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">

                                <header class="article-header">

                                    <h1 class="h2"><?php the_title(); ?> </h1>

                                    <p class="byline vcard"><?php _e('Posted', 'bonestheme'); ?> <time class="updated" datetime="<?php echo the_time('Y-m-j'); ?>" pubdate><?php the_time(get_option('date_format')); ?></time> <?php _e('by', 'bonestheme'); ?> <span class="author"><?php the_author_posts_link(); ?></span> <span class="amp">&</span> <?php _e('filed under', 'bonestheme'); ?> <?php the_category(', '); ?>.</p>

                                </header> <!-- end article header -->

                                <section class="entry-content clearfix">
                                    <?php the_content(); ?>
                                </section> <!-- end article section -->
<!-- close </a>  here -->
    </a>
于 2012-11-25T07:59:46.213 回答
0

您始终可以将JavaScript解决方案与CSS结合使用:

<article style="cursor:pointer;" onclick="window.location='<?php the_permalink(); ?>'">
  ...
</article>
于 2012-11-25T00:28:58.647 回答