Answer the question
In order to leave comments, you need to log in
How to get a list of post categories while disabling one of them?
Here is the recording cycle, I display it as the news of the day, however, each news of the day has its own category, and therefore in the link to the post category I need to bypass it and show the native category. How to disable this category in the submission of the name and link of the post category?
<?php $query2 = new WP_Query( array( 'posts_per_page' => 1, 'cat'=> 15 ) );?>
<?php if( $query2->have_posts() ){
while( $query2->have_posts() ){
$query2->the_post();
$cat = get_the_category();
$cat_ID= $cat[0]->term_id;?>
<div class="image-main-news">
<a href="<?php the_permalink() ?>">
<?php if(get_the_post_thumbnail_url($post->ID)) echo get_the_post_thumbnail( $attr); else echo ' <img alt="#" src="http://blogprogram.ru/wp-content/uploads/2016/05/noimg.png">'; ?>
</a>
</div>
<div class="header-news">
<div class="news-day">
<div class="news-day-title">
<h3>Новость дня</h3>
<a class="category-news" href="<?= get_term_link($cat[0])?>"><?= get_cat_name($cat_ID);?></a>
</div>
<div class="title-news-day">
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
</div>
</div>
<?php }
wp_reset_postdata();
} ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question