Created
July 18, 2018 09:44
-
-
Save tamimibrahim17/8d926d7eb4d1285c0b960148f563d5eb to your computer and use it in GitHub Desktop.
get_terms wp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include __DIR__.'/wp-load.php'; | |
// Get all category of wordpress site. | |
// Categories are actually term located in `wp_terms` table. | |
$categories = get_terms(); | |
// This will fetch all categories of all post type of the site. | |
print_r( $categories ); | |
// How can we fetch only a specific post type categories? | |
// By defining taxonomy | |
$product_cats = get_terms(array( | |
'taxonomy' => 'product_cat' | |
)); | |
print_r( $product_cats ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment