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

How to log information, warnings, errors In wordpress

To create a custom write_log() function for WordPress, you can use the error_log() function to write messages to the error log. This function will allow you to log information, warnings, errors, or any other messages during development or debugging.

Add Custom Price on Bulk Purchase in Woocommerce Using ACF

To achieve this functionality, you’ll need to create a custom ACF repeater field for quantity and price in the product admin panel and then display all the prices on the product single page. Additionally, you’ll have to calculate the price according to the selected quantity when a product is added to the cart using WordPress hooks.

Elementor shortcodes

Elementor is a popular page builder plugin for WordPress that allows you to create and customize web pages using a drag-and-drop interface. Elementor provides a wide range of built-in widgets and elements, and you can also create your own custom elements using shortcodes.