Returns an array of category objects matching the query parameters. Arguments are pretty much the same as wp_list_categories and can be passed as either array or in query syntax.

learn more… | top users | synonyms

-5
votes
0answers
13 views

add_filter( 'post_thumbnail_html') vs wp_get_post_categories($posts[0]->ID) [on hold]

Hi there I have a problem bacause of: function my_post_image_html( $html, $post_id, $post_image_id ) { $sowot = wp_get_post_categories($posts[0]->ID); $large_image_url = ...
4
votes
2answers
223 views

How to show subcategories in categories else show posts

I have hierarchy like this: Category1 -Subcategory1 -Subcategory2 --Post1 Category2 -Subcategory1 I need to show subcategories name and description when i go to category//// Now i use this code: ...
0
votes
0answers
16 views

Get array of parent and other child categories based on one child

I'm trying to modify a custom wp_query that's generating related posts. Currently, it's returning other posts in the same category, which is a sub-category. I'd like it to ALSO return posts from the ...
-2
votes
1answer
40 views

How to get if category has posts?

I have problem with getting get_category('2')->category_count number. I want to have list of news which are as a post in one category. I use plugin for insert php (I know it can be used by theme). ...
1
vote
1answer
924 views

Trying to sort and display categories(not posts) by custom field: 'order'

I'm a WordPress rookie. I've added a custom field to my "Category" taxonomy. The custom field is "custom_order" and its purpose is to hold a number so that my categories can be sorted and displayed in ...
0
votes
1answer
3k views

Display Categories or Subcategories with name & description in category.php

I have the following issue for my customer. Can some suggest a possible solution to this issue? This website has Categories & Subcategories Cat1 -Subcat1 -Subcat2 -Subcat3 Cat2 -Subcat1 -...
0
votes
0answers
13 views

Need help understanding get_the_category function parent-child order?

I am unable to understand how WP fills up the array which get_the_category function returns. This is the hierarchy of categories in two cases: Cat 1 > Cat 2 > Cat 3 Cat 1 > Cat 2 In the first case,...
0
votes
1answer
446 views

Compare current post Category in select menu

I have done this many times but not via a form so i am getting a weird issues when trying to assign a "selected" based on the current post term id... Maybe the use of _the_category and then ...
1
vote
5answers
13k views

Get current category id from post page wordpress

I have a problem to get category id of current post. We are using <?php get_the_category( $id ) ?> for finding out category of current post. If a post like 'demo' has 2 category like cat1 and ...
0
votes
1answer
562 views

How to sort category by custom field value

I am using the following : $catargs = array( 'meta_key'=> 'category_custom_order', 'orderby' => 'meta_value_num', 'order'=> 'ASC', ); but I can get the ...
0
votes
3answers
4k views

get_categories only getting categories in the main language

I am trying to retrieve in the "content composer" the categories of projects based on the active language. But i only get the categories off the main language, never on the other. My code is: ...
-1
votes
0answers
20 views

how to get the child categories of products in the spicial style

I work on themes i get and can't know how to redesign the component to get what i need so i get the HTML of the element i need from the Pagebuilder in the theme and i make some search and find this ...
0
votes
1answer
443 views

WP Dropdown Categories, display subcategories but not grandchildren categories?

So my main goal is to create 3 drop-down category options to run a search. It's for a car website, so I have 3 parents, "Make", "Model", and "Year" At the moment I have the following code <?php $...
0
votes
1answer
450 views

Get current_parent_category in a loop or Cat ancestor- big problem

Im having some trouble since a week now . .. I'm having a bad time with that ! I explain my situation: I have setup a style for post category. (a background-color and a small image background). ...
0
votes
2answers
624 views

Display Random Thumbnail from Category

I have a feeling that I'm on the right track, I just don't have enough solid PHP knowledge to get much further than where I'm currently at. I'm currently using the following code to return a list of ...
0
votes
0answers
19 views

how do i add an array of objects or an extra field to a wordpress json api core controller?

Is there a way to add an array of objects to a core controller of the json api plugin the core controller i want to modify is 'get_category_index' and it returns these objects id post_count name ...
0
votes
1answer
17 views

Store All Post Categories In Array

I'm trying to collect a list of all categories used on posts. However, the following code only returns the first category. How could this be adapted to collect all categories, if the post has ...
0
votes
1answer
22 views

How can I ask to an existing category?

I want to echo the child category name. That works. But how can I ask after an existing category, so that I have no <h6>-tag when I have no category? Where is my mistake? <?php $...
0
votes
1answer
16 views

Parent and child relation code and display only first child list

for Indoor -for bedroom --TFL ---8u ---9u --MFL ---10u ---11u -for Kitchen --ABC ---4u ---5u --XYZ ---6u ---7u These are the category listing... when user click on the for bedroom at that time show ...
1
vote
1answer
818 views

Listing Specific Categories from Current Post with Depth

I've been on this for sometime and been having a ton of issues to find a proper way to do what I'm trying to achieve. An Example would be as follows: I have a featured Image with a rollover and I ...
0
votes
0answers
57 views

Proper way of listing posts from custom archive with sub-categories

I am trying to create a register of things, using custom post type, named register, and custom taxonomy named register_cat. It will have categories and sub categories, something like this: Cat A ...
1
vote
0answers
31 views

Get image from parent category

I am creating a page which shows all post categories and image associated with the categories. Each category has a textbox for the user to paste an image's URL and the page will then display the ...
2
votes
0answers
22 views

get / list categories and counts filtered by custom taxonomy term

In my post 'post type' besides "categories" I've a custom taxonomy called "product-types". The category is actually more "manufactures" of the product types. I've a product-types page where I list ...
1
vote
1answer
50 views

Detect whether a page is a product subcategory page?

How can I detect whether current page is a product sub category page? I've tried with the following but it will always print out "NO" function is_subcategory($category = null) { if (is_category()...
3
votes
1answer
295 views

Listing a post's categories and subcategories

Is there a way to display the parent categories and subcategories for a particular post (ie. for use on single.php). I've tried using get_the_category_list(), but it displays a list like this: ...
0
votes
1answer
38 views

Loop categories by recent post

Im looking for a way to loop through categories and then display the recent posts for each one in a container but I need a way to sort the categories by which ones have the most recent posts So if ...
0
votes
4answers
6k views

How to order the get_categories result

I read the documentation of the codex but i can't order the get_categories() result just like parent,childrens. I have these kind of categories' three: -Events - Music - Culture - ...
1
vote
1answer
39 views

Custom category order with get_categories

I have a site with metro_creativex theme with side menu that displays categories in an alphabetic order. Now I need to sort them by my own order (that's not alphabetical reverse or by id) and, since ...
0
votes
0answers
34 views

Show name of post category, and name of category parrent (if category has parent)

Example: I have category named "Food" and inside that category another category named "Fruit". How to show name of post category, and its parent category (it category has parent category). After ...
0
votes
1answer
130 views

How to display get_categories selected category?

I'm creating a widget, and I'm displaying categories list in form function: echo '<select name="categories">'; // Add custom option as default echo '<option>' . __('No Category', '...
0
votes
1answer
190 views

Add inline style to get_the_category_list

I need to style the get_the_category_list() a tag but can't seem to find a way. This is my code: echo '<ul class="list-inline meta-list">'; // Get the categories $terms = get_the_terms(...
1
vote
1answer
226 views

How to get category image custom post type taxonomy in wordpress?

I have a custom post estate_property and its has taxonomies property_category ,propert_action.I have installed WPCustom Category Image to upload image for each category of taxonomies. How to display ...
1
vote
1answer
33 views

Get categories with posts by custom field value

I have a big categories tree (~2000 total subcategories)... And I have a lot of posts with custom field "city" (different values). I have created filter posts by "city" field. But I have problem with ...
3
votes
1answer
150 views

How to list all categories and tags in a page?

Suppose we have few categories, tags and custom post type and taxonomies. How can we list all categories, tags in a page? Something like; Page Category Thumbnail and Category Name 1(link to ...
1
vote
0answers
26 views

How to show custom taxonomy in the permalink?

I used the Portfolio Post Type Plugin to create custom tax and post type. I would like to show the custom taxonomy on the portfolio projects. portfolio/customtaxonomy/project while now is ...
0
votes
2answers
69 views

Get Category Archive Template Name Dynamically

I'm making a category archive template that works for all my categories. I need to dynamically set the 'category' parameter of WP_Query inside of this template to make it work. How do I dynamically ...
0
votes
2answers
54 views

How to display taxonomy terms the way they are hierarchical

Reading Kaiser's query and Scribu's answer I'm now in an ocean of no shore. I made a custom taxonomy, where I want to show the terms as per their hierarchy, like below: Level 0 -- Level 1 --- Level 2 ...
1
vote
3answers
2k views

get only sub category ID

i need to get only sub category ID. i already get sub category id but it coming with main category id too bellow is code <?php while ( have_posts() ) : the_post(); ?> <option value=".<?...
0
votes
1answer
56 views

Show category with link

I am trying to show the category of posts with link to its page, so I used this code but I don't know What's wrong with it. It is only showing the category without link. <p class="subjectCat">&...
0
votes
2answers
70 views

Show all sub categories?

Is it possible to show all child/sub categories of all parent cats? I have the following hierarchy: Parent Cat/Tax -- Sub 1 -- Sub 2 Parent Cat/Tax 2 -- Sub 1 -- Sub 2 I would like to be able to ...
0
votes
1answer
44 views

Difference between wp_list_categories and get_categories

Whats the difference between the wp_list_categories and get_categories? Wordpress codex says use get_categories if needs a function that does not format the results what format is this ...
1
vote
3answers
3k views

How do I get the category slug from wp_dropdown_categories

I am customizing a plugin. I needed it to show a list of the categories in hierarchy, which I got working with all of the functions of the plugin. I'm using wp_dropdown_categories, but I'd like to ...
0
votes
0answers
34 views

Getting posts for a category

I have a menu made up of categories, click a category shows the users list of articles beloging to said category. However I seem to have stumbled across a problem if a post belongs to 2 or more ...
0
votes
1answer
77 views

List posts of assigned categories in list of all categories on single.php

here's what I'm trying to accomplish: I've got several categories, each of them have several posts. Now, on category.php I'm able to output a list of all categories and, inside this list, show a list ...
0
votes
1answer
65 views

Group child category IDs based on their parent category

I have IDs for my child categories, 11,14,21,35,38,39, where these all are various child categories from their main category: Parent category 1 has: 11,14 Parent category 2 has: 21 Parent category 3 ...
0
votes
1answer
242 views

using checked function to verify value against an array

I have a 2-level taxonomy terms checkbox list (created with get_categories) that stores values into the usermeta table. I'd like to display the checked items when the page is refreshed. This is the ...
0
votes
0answers
24 views

Order get_categories() by the order they show up in the backend

I am using Woocommerce and have 1800 products that are in 18 different categories. The idea is to have a page display these 18 different categories as links to their archives. The problem is I want ...
0
votes
1answer
351 views

Get the child category ID of current category

I am trying to get the category ID of the child (no grand children) of the current category. Using below method: $category = get_category(get_query_var( 'cat' )); // get category ID $catid = $...
2
votes
1answer
18k views

Display current category title on category page

Using the following code in a category template, but instead of showing the current category page that I am on, it displays the first category of the first post. For example on Food category page it ...
2
votes
1answer
159 views

Category Archive, list subcategories of each post

I found this post, but it was never answered. I'm looking for the same thing, haven't been able to find a solution so far. My problem is that I can't find a way to list subcategories unique to each ...