Try this :
// This converts the WP_Term Object to array.
$catlist = json_decode(json_encode($catlist),true);
$category_id = array_column($catlist, 'cat_ID');
print_r($category_id);
Related Posts:
- Get categories names as an array to use it in theme settings
- How to get the last category name of a child category?
- Output category list inside array
- How To Pass Array To get_the_category_by_ID() and Get An Array Back?
- Finding and removing duplicates within WP Arrays
- Using multiple variables to assign categories to an array
- How to filter specific element of an array in wordpress/php?
- wp_get_archive for category returning different URLs on different but similar sites
- !in_array doesnt recognize category
- PHP Array Returning [object Object]. Tried existing answers results with no luck
- foreach loop still echoes array
- selected option if current category is the value
- get_template_part based upon post’s category
- Exclude posts based on meta value
- how to save selected option in variable for rest api category filter
- Setting default category base on theme activation
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Hide subcategories (widget)
- Alert Bar section within WP loop is displaying even though there are no posts
- Let Users Choose Post Categories
- Different post styles depending on category
- Display category name only once inside loop
- Checking array against author id in loop
- How to show only subcategories in parent category not parent category?
- how to show only specific category for a template
- Redirect to another page using contact form 7? [closed]
- Alter required message using comment form api
- Dilemma of Populating all the categories in a drop down list
- Display most popular posts of category
- Advanced Custom Fields – display label and value only if value entered
- meaning of (array)function()
- Grouping posts by a custom meta value
- Create menu locations for each category in wordpress
- Creating sub-categories via php
- Define specific category name in PHP
- Edit the_category (); for a hierarchical display
- JSON REST API WordPress only showing first 10 categories
- Category title output before opening title tag
- wp_force_remove_style’ not found
- get taxonomy thumbnail and use it as a variable in code
- Include Parent Term in wp_list_categories
- How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286
- How can I access string value in an array?
- How to use if statement in an array? [closed]
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- Filtering a function’ output for a new continued function
- Get html data with javascript to php array and store to wordpress database
- Get all categories post is not in
- Get latest post from all categories except one
- How do I create a numbered list with PHP? [closed]
- Displaying posts based on category
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- How do I remove a category from a wordpress loop>
- How to use array in function to get only value I want
- Error while setting role
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- How to say if meta_value is greater than 0 in an array?
- How to use two meta_compare in an array?
- Warning: in_array() null given in PHP function
- Foreach loop inside an array_merge
- In WordPress, how do I get the number of posts next to single_cat_title(”); in the category.php file?
- Use get() method to grab all categories and output inside another method
- Loop over Array and get the distinct ids
- Only show size attributes in product box woocommerce when available
- How to access or parse key/values that have “string”
- If Array Values Match Another Array’s Values, Then
- Remove empty terms from array, sort alphabetically, update back to repeating field
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Only show first image in foreach loop
- Conditional multidimensional arrays and array_map
- How to get category name or ID by post?
- Custom post type category not displaying category ID
- Argument for if term-> have child?
- How to get current post category details inside “loop”?
- How to separate categories with commas?
- How can I get all values from my array in a loop in php? [closed]
- Getting posts to exclude from array
- Get all posts as an array ID => Name
- How to hide posts of a specific custom category in WordPress?
- Show all tags within a category?
- Post not populating for custom post type based on category selection
- Add new post in existing categories using wp_insert_post
- I’m unable to call img path using single quotes in an array?
- Filter by field with array value in ACF on WP REST API
- How to change logo by category
- extract serialized array to use for wp-query
- Problem with custom loop and wp_list_pluck [closed]
- Listing titles and custom fields of entries within subcategories
- get users search not working with array
- random display categories – change url
- Displaying list of posts in category page
- Echoing a CSS class based on category of post in a list
- Comapare get_user_meta value
- How can get all users by current user meta?
- Alphabetically Ordered Category in WordPress
- Get the id of all images in a post
- Do not duplicate posts with multiple categories in multiple loops
- how to make an array of post id’s in is_single
- How can I split my query result in 2 arrays?
- Loading Posts & Category with Ajax