WP Query taxonomy.php 显示当前词条的帖子 [英] WP Query taxonomy.php to display posts from current term
问题描述
我在我的 taxonomy.php
文件中使用以下 wp_query
来尝试显示来自该分类法的术语内的帖子列表.
我也有 6 个分类法,我希望将其应用于,所以我想制作 $args 'taxonomy' =>'topic'
和 'terms' =>'arabisation'
动态,与用户正在查看的当前页面相关.
谢谢
<?php get_sidebar();?><section id="英雄形象"><div class="gradient-overlay"><?php//变量$queried_object = get_queried_object();$taxonomy = $queried_object->taxonomy;$term_id = $queried_object->term_id;$image = get_field('image', $taxonomy . '_' . $term_id);//加载此分类术语的图像(术语对象)echo '<img src="'.$image['sizes']['large'].'"/>';?>
<div class="grid"><header class="unit full-width"><a href="<?php echo home_url(); ?>/" title="Kurdistan Memory Programme" class="logo"><?php bloginfo('name');?></a></标题><footer class="单元二分之一"><h1><?php single_cat_title();?></h1><h4 class="scroll-down">向下滚动以继续</h4></页脚>
</节><主类=网格"><?if ( have_posts() ) : ?><?while ( have_posts() ) : the_post();?><div class="unit col-6-12"><figure class="缩略图"><?如果 ( has_post_thumbnail() ) {the_post_thumbnail();?><图说明><h4><?标题();?></h4><h5><?the_excerpt();?></h5><h6><a href="<?the_permalink(); ?>">查看项目</a></h6></figcaption></图>
<?终了;?><?万一;?></main><?php get_footer();?>
Taxonomy.php 文件已经运行了一个查询,该查询返回应用了该分类术语的帖子,所以试试这个:
<?php while ( have_posts() ) : the_post();?><div class="unit col-6-12"><figure class="缩略图"><?php if ( has_post_thumbnail() ) {the_post_thumbnail();?><图说明><h4><?标题();?></h4><h5><?the_excerpt();?></h5><h6><a href="<?the_permalink(); ?>">查看项目</a></h6></figcaption></图>