Since I don't want to make the mistake

Transform business strategies with advanced india database management solutions.
Post Reply
thenazmusss
Posts: 16
Joined: Sat Dec 21, 2024 4:09 am

Since I don't want to make the mistake

Post by thenazmusss »

I made in some previous article where, in a few words, I showed you how to implement a CPT but then I didn't show you how to display it in the frontend, here I am immediately fixing it!

If you have been developing with WordPress for a while now you should know that there are specific functions to call categories and tags. Thanks to the_category()oa the_tags()we are able to show these elements respectively, but these are helper functions list of pakistan consumer email that have been provided to us by WordPress to go and call these standard taxonomies belonging to the platform.

How to display our newly created taxonomy?

Remember when I told you to keep in mind the abbreviation (I prefer the slug ) that we used to record the taxonomy? That word in quotes is nothing more than the first parameter of the function register_taxonomy() ; the one we called prodotti.

Well, it's time to start using it!

PHP
1
//Create the configuration array
2
$args = array (
3
'taxonomy' => 'products' , //slug taxonomy
4
'orderby' => 'name' , //ordering
5
'show_count' => 0 , //1 for yes, 0 for no
6
'pad_counts' => 0 , //1 for yes, 0 for no
7
'hierarchical' => 1 , //1 for yes, 0 for no
8
'title_li' => 'Product List' //Add a title
9
);
10

11
//Show Categories
12
wp_list_categories ( $args );
As you should be getting used to by now, the code I presented to you also has a configuration array. taxonomyThe slug of the taxonomy we want to list will be inserted into the key, all the other parameters are the classic parameters that you can use with the function wp_list_categories()that, in this case, helps us to show all the elements of our taxonomy .

With the code I just presented you will be able to add all the entries of your new taxonomy anywhere in your project , all you have to do is call this simple function and you are done.
Post Reply