Answer the question
In order to leave comments, you need to log in
How to display a link to a custom category for a custom post?
Hello everyone, I ran into the following problem: For the custom post type games, you need to display the main category specified for it (the post can belong to several categories). The custom taxonomy is called gamecat
<?php the_terms( $post->ID, 'gamecat', '', '','' ); ?>
<?php
$archives_meta = get_theme_mod( 'archives_post_meta', 1 );
if ( $archives_meta == 1 ) {
$category = get_the_category();
if ($category) {
echo '<span class="cat"><a href="' . get_category_link( $category[0]->term_id ) . '" title="' . sprintf( __( "Рубрика %s", "mmogames" ), $category[0]->name ) . '" ' . 'class="aprevcat" rel="category tag"><span itemprop="articleSection">' . $category[0]->name.'</span></a></span>';
}
} ?>
Answer the question
In order to leave comments, you need to log in
Так же, как во втором примере для категорий, только используйте get_term_link() и get_term().
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question