カスタム投稿タイプのすべての投稿をループしたいのですが、それらをループすると特定の用語でタグ付けされた投稿にクラスが追加されます。Wordpress - 特定の用語ループに特別なクラスを追加する
私は現在以下の機能を持っていますが、これは特定の用語で記事を投稿するだけで、横にある投稿のすべてではありません。上記
$projects_posts = post_type_tax_query('projects', 'locked', '5');
if($projects_posts){ ?>
<ul class="full-width projects-grid grid list-style-none">
<?php $counter = 1; ?>
<?php foreach ($projects_posts as $project):
$project_title = get_field('project_title', $project->ID); // get all the rows
$project_image_thumbnail = get_field('project_thumbnail_image', $project->ID); ?>
<li class="animation-element bounce-up delay-motion-<?php echo $counter; ?> col-lg-4 col-xs-12 col-sm-6">
<a href="<?php echo the_permalink($project->ID); ?>" target="_blank">
<figure class="effect-milo">
<img src="<?php echo $project_image_thumbnail; ?>"/>
<h4><?= $project_title; ?></h4>
</figure>
</a>
</li>
<?php $counter++; ?>
<?php endforeach; ?>
</ul>
<?php } ?>
と私の現在のループはちょうど私はそれがすべての記事をループしますが、用語5.これで、特定のポストにクラスを適用することを確認するために、上記の編集可能性がどのように思って
/**
* Get posts of particular termID
*/
function post_type_tax_query($post_type=null, $taxonomy=null, $term_id=null){
$args = array(
'posts_per_page' => -1,
'post_type' => $post_type,
'orderby' => 'post_date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'id',
'terms' => $term_id
)
)
);
$the_query = new \WP_Query($args);
$queryitems = $the_query->get_posts();
return $queryitems;
}
スタイリングのためのものです。
おかげで、
DIM3NSION私が正しく多分このような何か質問を理解している場合、私は知らない