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

Jquery Form Validator With User Name Exist User Email Exist

To implement jQuery Form Validator with the specified validation rules, including required, minlength, email, equalTo, custom validation, confirm password, username pattern, email existence in the database in WordPress, and username with no numeric value, you’ll need to combine client-side validation using jQuery Form Validator with server-side validation using PHP and WordPress functions.

How To Add New Post Type And Custom Taxonomy

In WordPress, `register_post_type` and `register_taxonomy` are essential functions that allow you to create custom post types and custom taxonomies, respectively. Custom post types and taxonomies give you the flexibility to organize and display different types of content beyond the default posts and pages.