Pawan Kumawat

Fetch WordPress Categories

Now Days WordPress is a popular blogging platform which have many inbuilt functions.For fetching wordpress categories, wordpress provide lots of inbuilt functions like get_categories(), wp_list_categories(), wp_dropdown_categories().

 

A. get_categories()
Using This function we can fetch wordpress categories.

//Fetching categories in string format.
<?php
   get_categories(style=list&hide_empty=1);
?>
//Fetching categories in object format.
<?php
   $options = array('style' => 'list','hide_empty' => 1,);
   get_categories($options);
?>

 

B. wp_list_categories()
Using This function we can fetch wordpress categories in html format.

//Fetching categories in string format.
<?php
   wp_list_categories(style=list&hide_empty=1);
?>
//Fetching categories in object format.
<?php
   $options = array('style' => 'list','hide_empty' => 1,);
   wp_list_categories($options);
?>

 

C. wp_dropdown_categories()
Using This function we can fetch wordpress categories in dropdown list box.

//Fetching categories in string format.
<?php
   wp_dropdown_categories(style=list&hide_empty=1);
?>
//Fetching categories in object format.
<?php
   $options = array('style' => 'list','hide_empty' => 1,);
   wp_dropdown_categories($options);
?>

 

Categories

Related Blogs

Add Custom Taxonomy Filter on Products Dashboard.

How To Filter Products by Taxonomies in the Dashboard?

WooCommerce provide Many Product filters on admin screen , such as “Select a category”, “Filter by product type”, “Filter by stock status”.

Convert PHP Array into JavaScript Array.

To convert both a normal PHP array, a multidimensional PHP array, and a nested PHP array into JavaScript arrays, you can use JSON encoding and decoding as previously explained. JSON is well-suited for handling various data structures, including both simple arrays and complex nested arrays.

WordPress Ajax login

To implement Ajax login in WordPress, you can follow these steps: 1. Open the theme’s functions.php file in your WordPress