Answer the question
In order to leave comments, you need to log in
Can't deal with 404 when going through taxonomy?
People, I ask you to explain (chew) me ...
There is an arbitrary entry: need
A taxonomy has been created for it: help
As a result, in the admin panel, in the left panel there is:
Need => All Need
Add Need Need
Categories Need
If we fall into the Need Categories, then the address is at us like this:
http://localhost:8089/wp-admin/edit-tags.php?taxonomy=help&post_type=need
http://localhost:8089/need/testovaya-zapis-1/
https://developer.wordpress.org/reference/classes/wp_query/#taxonomy-parameters
<?php
$args = array(
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'help',
'field' => 'slug',
'terms' => 'all',
),
),
);
$query = new WP_Query( $args );
?>
<?php
$number = 0; // 0=все рубрики. Можно ограничиться кол-вом рубрик указав соответствующую цифру.
$args = array(
'number' => $number,
'orderby' => 'count',
'order' => 'DESC'
);
$terms = get_terms('help', $args);
if($terms){
echo '<ul>';
foreach ($terms as $term){
echo '<a href="">';
echo "<li>{$term->name}{$term_id->ID}";
echo '</a>';
echo " ({$term->count})</li>";
// рядом в скобках указываем количество записей в категории
}
echo '</ul>';
}
?>
<?php
$term_slug = 'notall'; //передавать нужно альтернативное имя (slug)
$term_link = get_term_link($term_slug, 'help');
echo '<a href="'. $term_link .'">ссылка на раздел '. $term_slug .'</a>';
?>
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