K
K
Kirill Krivitsky2015-05-19 19:23:35
CMS
Kirill Krivitsky, 2015-05-19 19:23:35

Show category description in wordpress?

Hello, I can’t figure out how to display a category description on WordPress, I tried different options. There is one catch, this is not just displaying the category of posts, but categories from the portfolio section, i.e. no standard solution needed.
Here is part of the code, I think it will come in handy, I don’t understand anything in php at all

$query_array = array(
      'post_type' =>  'portfolio',
      'posts_per_page' => $ipp,
      'paged' => get_query_var('paged'),
      'tax_query' => array(
            array(
            'taxonomy' => 'portfolio_category',
            'field' => 'slug',
            'terms' => $post_port,
            'operator' => 'IN'
            )
      )
    );

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2015-05-20
@KrivitskiyKirill

Without going into theory, and analysis of your code, in this case, you need to get it like this

$term = get_term_by('slug', $post_port, 'portfolio_category');
echo term_description($term->term_id, 'portfolio_category');

The love of showing everyone through page templates sometimes kills, it was enough to use
the taxonomy-portfolio_category.php template and life would become much easier

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question