Я создал пользовательский тип поста и отображаю посты на странице архива, но хочу отображать посты разных категорий на одной странице. Вот так:
Но мои посты сейчас такие:
Как мне этого добиться? Я много искал, но не нашел решения для этого. Вот почему я задаю вопрос здесь. Вот мой код:
<section class="careerBlogs">
<div class="container">
<div class="row with-gutters">
<?php
$args = array (
'post_type' => array( 'career' ),
'post_status' => array( 'publish' ),
'nopaging' => true,
'order' => 'ASC',
'orderby' => 'menu_order',
);
$templates = new WP_Query( $args );
if ( $templates->have_posts() ) {
while ( $templates->have_posts() ) {
$templates->the_post(); global $post;
$customVars = get_post_meta($post->ID, 'custom_vars', true);
if(!empty($customVars)){
$isRemotely = $customVars['remotely'];
}
// Categories
$categories = get_the_terms( $post->ID, 'career_category' );
foreach( $categories as $category ) { ?>
<div class="col-xs-12">
<div class="careerBlogs--title">Open Positions in <?= $category->name; ?></div>
</div>
<?php } ?>
<div class="col-xl-12">
<div class="card mb-4">
<a href="<?= get_the_permalink(); ?>" class="card-link">
<div class="card-info">
<div class="card-title"><?= get_the_title(); ?></div>
<div class="location">
<span>Lahore</span>/<span><?= $isRemotely ? 'Remote' : '' ?></span>
</div>
</div>
</a>
</div>
</div>
<?php } } else {
echo 'no posts to show';
}
wp_reset_postdata();
?>
</div>
</div>
</section>
На моей странице archive-career.php
. Можете ли вы помочь мне достичь этого? Я застрял здесь