【发布时间】:2014-11-26 15:56:13
【问题描述】:
我真的很难找出在哪里或如何在我的 wordpess 帖子页面中引入分页...
<?php
if (is_tag()) {
$args = array('tag_id' => get_queried_object_id());
} else {
$args = array('cat' => get_queried_object_id());
}
$i=1;
$latest_blog_posts = new WP_Query( $args );
if ( $latest_blog_posts->have_posts() ) : while ( $latest_blog_posts->have_posts() ) : $latest_blog_posts->the_post();
foreach((get_the_category()) as $category) {
$cat_name = $category->cat_name;
$cat_link = get_category_link( $category->term_id );
}
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 2600,1000 ), false, '' );
?>
<div style="height: auto; overflow: auto;">
<div style="float: left; margin-right: 15px;">
<div style="background: url(<?php echo $src[0]; ?> ); width: 330px; height: 260px; background-size: cover; background-repeat:no-repeat;">
</div>
</div>
<div style="float: right; width: 600px;">
<h2 style="margin:0; padding: 0;"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p><span style="font-weight: 200; color: #aaa;">| <?php the_time('j F Y'); ?></span></p>
<p style="line-height: 160%;"><?php echo substr(get_the_excerpt(), 0,500); ?> [...]</p>
<?php echo get_the_tag_list('<p> | ',' | ','</p>'); ?>
<?php $archive_year = get_the_time('Y'); ?>
</div>
</div>
<?php if ( has_post_thumbnail() ) : ?>
<?php else: ?>
<?php endif; ?>
<?php $i++; endwhile; endif; ?>
该文件具体命名为 category-blog.php
我不确定我需要在分页中添加的脚本中的哪个位置,我试图了解示例在法典中的哪个位置与我如何使用我的内容有关。
【问题讨论】: