我目前正在开发我的第一个大型WordPress网站,我的档案中遇到了一个大问题。php文件。它加载所有帖子,而不是我要显示的类别/标签。
其基本思想是建立一个文章展示栏,其中前6篇文章将显示为thumnails,其余将以正常格式显示。然后分页开始,用户可以单击以查看下一页的结果,其中将显示相同的文章展示,但会显示下一页的标准帖子。为了做到这一点,我使用了两个循环,其中第二个循环被6个帖子抵消。直到昨天晚上,我才开始使用它,当时我更改了一些内容并重新加载,结果该内容才开始显示网站上的所有帖子。我最初认为这是我对标准帖子的查询问题,所以我对其进行了更改,但现在我看不出有什么理由它不起作用。
<?php get_header(); ?>
<div id="content">
<div id="inner-content" class="wrap cf">
<div id="main" class="m-all t-2of3 d-5of7 cf" role="main">
<?php //Check to See If We Are Looking for Posts Of A Specific Category ?>
<?php if (is_category()) {
?>
<h1 class="archive-title h2">
<span><?php _e( \' \', \'bonestheme\' ); ?></span> <?php single_cat_title(); ?>
</h1>
<?php //Check to See If We Are Looking for Posts With A Specific Tag ?>
<?php } elseif (is_tag()) { ?>
<h1 class="archive-title h2">
<span><?php _e( \' \', \'bonestheme\' ); ?></span> <?php single_tag_title(); ?>
</h1>
<?php //Check to See If We Are Looking for Posts From A Specific Author ?>
<?php } elseif (is_author()) {
global $post;
$author_id = $post->post_author;
?>
<h1 class="archive-title h2">
<span><?php _e( \'Posts By \', \'bonestheme\' ); ?></span> <?php the_author_meta(\'display_name\', $author_id); ?>
</h1>
<?php //Check to See If We Are Looking for Posts From A Specific Day ?>
<?php } elseif (is_day()) { ?>
<h1 class="archive-title h2">
<span><?php _e( \'Posted Today:\', \'bonestheme\' ); ?></span> <?php the_time(\'l, F j, Y\'); ?>
</h1>
<?php //Check to See If We Are Looking for Posts From A Specific Month ?>
<?php } elseif (is_month()) { ?>
<h1 class="archive-title h2">
<span><?php _e( \'Posted This Month:\', \'bonestheme\' ); ?></span> <?php the_time(\'F Y\'); ?>
</h1>
<?php //Check to See If We Are Looking for Posts From A Specific Year ?>
<?php } elseif (is_year()) { ?>
<h1 class="archive-title h2">
<span><?php _e( \'Posts This Year:\', \'bonestheme\' ); ?></span> <?php the_time(\'Y\'); ?>
</h1>
<?php } ?>
<?php //Begin Archive Article Showcase ?>
<div id="archive-article-showcase" class="article-showcase">
<?php
$arcshowcaseargs = array(
\'showposts\'=> 6,
\'caller_get_posts\'=>1
);
$my_query1 = new WP_Query($arcshowcaseargs);
if( $my_query1->have_posts() ) {
while ($my_query1->have_posts()) : $my_query1->the_post();
?>
<a href="<?php the_permalink() ?>" rel="bookmark" class="archive-article-showcase-thumbnail">
<?php if (class_exists(\'MultiPostThumbnails\')) :
MultiPostThumbnails::the_post_thumbnail(get_post_type(),\'secondary-image\', NULL,\'square-icon-large\');
endif; ?>
LOL
</a>
<?php
endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>
</div>
<?php //End Archive Article Showcase ?>
<?php
$maincaseargs = array(
\'offset = 6\',
\'caller_get_posts\'=>1
);
$my_query3 = new WP_Query($maincaseargs);
if( $my_query3->have_posts() ) {
while ($my_query3->have_posts()) : $my_query3->the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class( \'cf\' ); ?> role="article" style="position: relative; padding: 5px; border-bottom: 1px dashed #d4d8d8;">
<div class="rel-box" style="position: relative;">
<div class="thumbnail" style="display: inline-block;">
<?php echo get_the_post_thumbnail(NULL, \'main-loop\') ;?>
</div>
</div>
<div class="archive-article-holder">
<header class="article-header">
<h1 class="h2 entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
<p class="byline vcard">
<p class="pureSpan">By <?php the_author(); ?></p>
</p>
</header>
<footer class="article-footer cf" style="border: 0px;">
<p class="footer-post-date">
<?php printf( __( \'\', \'bonestheme\' ) . \' <time class="updated" datetime="%1$s" pubdate>%2$s</time> \' . __(\' \', \'bonestheme\' ) . \' \', get_the_time(\'Y-m-j\'), get_the_time(get_option(\'date_format\')), get_the_author_link( get_the_author_meta( \'ID\' ) )); ?>
</p>
<span> | </span>
<p class="footer-comment-count">
<?php comments_number( __( \'<span>No</span> Comments\', \'bonestheme\' ), __( \'<span>One</span> Comment\', \'bonestheme\' ), _n( \'<span>%</span> Comments\', \'<span>%</span> Comments\', get_comments_number(), \'bonestheme\' ) );?>
</p>
</footer>
</div>
</article>
<?php endwhile; ?>
<?php bones_page_navi(); ?>
<?php else : ?>
<article id="post-not-found" class="hentry cf" style="border-bottom: 1px dashed #d4d8d8;">
<header class="article-header">
<h1><?php _e( \'Sorry, No Results.\', \'bonestheme\' ); ?></h1>
</header>
<section class="entry-content">
<p><?php _e( \'Try your search again.\', \'bonestheme\' ); ?></p>
</section>
<footer class="article-footer">
</footer>
</article>
<?php endif; ?>
</div>
</div>
</div>
<?php get_footer(); ?>