我正在处理WordPress主题,这是我显示帖子的代码。
然而,我很难显示一篇文章的所有类别。大多数解决方案不适用于我,但适用于其他人。这也是我在这里发布完整代码的原因,因为此代码可能不是最佳使用代码。
提前感谢!
<?php
$wpb_all_query = new WP_Query(array(\'post_type\'=>\'post\', \'post_status\'=>\'publish\', \'posts_per_page\'=>-1));
if ( $wpb_all_query->have_posts() ) :
while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post();
?>
<article id="post-5" class="slide taken" data-background-l="dark" data-background-p="dark" itemscope itemtype="http://schema.org/CreativeWork">
<header class="page-header caption">
<div>
<h2 class="title" itemprop="name"><?php the_title(); ?></h2>
<h6 class="subtitle"><?php echo $cats[0]->name; ?></h6>
<div class="excerpt" itemprop="description"><p><?php the_excerpt(); ?></p></div>
<a class="mitch-button to-load dark" href="<?php the_permalink(); ?>" data-i="1" data-title="Lapka"><span>View Post<svg xmlns="http://www.w3.org/2000/svg" x="0" y="0" width="24" height="42" viewBox="0 0 24 42" enable-background="new 0 0 24 42" xml:space="preserve"><polygon fill="dark" points="23.3 20.1 23.3 20.1 23.3 20.1 20.1 23.3 20.1 23.3 3.1 40.3 0 37.1 17 20.1 0 3.1 3.1 0 20.1 17 20.1 17 "/></svg></span></a>
</div>
</header>
<div class="media" data-bg-small="/wp-content/uploads/2015/11/1-1-1920x1071.jpg" data-bg-full="/wp-content/uploads/2015/11/1-1.jpg" data-bg-small-p="/wp-content/uploads/2015/11/1_vertical-855x1140.jpg" data-bg-large-p="/wp-content/uploads/2015/11/1_vertical-1110x1480.jpg" data-bg-full-p="/wp-content/uploads/2015/11/1_vertical.jpg">
<img src="/wp-content/uploads/2015/11/1-1-960x535.jpg" alt="Lapka" data-lazyload="innoway" itemprop="image" srcset="data:image/gif;base64,R0lGODlhAQABAJH/AP///wAAAMDAwAAAACH5BAEAAAIALAAAAAABAAEAAAICVAEAOw==" />
</div>
</article>
<?php
endwhile;
wp_reset_postdata();
else :
_e( \'Sorry, no posts matched your criteria.\' );
endif; ?>