I
I
Igor Pushkarsky2015-11-04 09:51:45
WordPress
Igor Pushkarsky, 2015-11-04 09:51:45

How to display a list of subcategories in your format?

Hello everyone, this is a question!
How can I display all subcategories in this format

<li itemscope itemtype="http://schema.org/Book" >
                	<a itemprop="url" href="#">
                    		<img  itemprop="image" src="images/cover/veshevedenie.png" alt="Обложка книги Вещеведенье"/>
                            <span itemprop="name">Вещеведенье</span>
                    </a>
                  <meta itemprop="dateModified" content="2013-09-07">
                  <meta itemprop="author" content="Евгений Узденский">
                  <meta itemprop="inLanguage" content="ru-RU">
                  <meta itemprop="bookFormat" content="Paperback">
                  <meta itemprop="numberOfPages" content="7">
                </li>

In principle, there is a solution but it is not complete, there are no pictures and there is no support for the meta description.
Maybe it can be upgraded somehow?
<?php $sub_cat = wp_list_categories( array(
                        'hide_empty' => 0,
                        'child_of' => 9
                    ));?>

                    <?php echo $sub_cat ?>

For images, I installed the plugin "Images of taxonomies"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2015-11-04
@RainMEN

Use get_categories()
Returns an object with data about the category
All the metadata you need is missing from the standard categories API, and therefore will not be returned in any way.
However, they can be easily added using this method . How to write a category template correctly?
get something like this
Or, as a light option, you can add them to the category description through a separator
somehow, like so

$array = explode('%%',category_description());
// URL изображения будет лежать тут  - $array[0];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question