WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to do a small modification on WP site done by someone else. And my WP experience is close to zero. But I'm comfortable with PHP.

Wordpress Version: 3.8


ONLY Advanced Custom Fields 4.3.4 [ACF] http://wordpress.org/plugins/advanced-custom-fields/

There's only one group Products made with ACF with fields like title, description, price, store. Site owner add Products with details & which stores they are available at.

currently the products are displayed correctly based on the url


will take to a list of product categories. When user clicks any of the category it will show the filtered products list with the ACF field store

The Problem

All categories are displayed regardless of whether it contain products for the specific stores

ie., category 2 has only one product product 10 and it is only available in store1. But store2 & store3 shows category 2 even though it doesn't have any valid product.

Currently the following code is used to display categories.

$args = array(
    'type'                     => 'post',
    'child_of'                 => 0,
    'parent'                   => '0',
    'orderby'                  => 'name',
    'order'                    => 'ASC',
    'hide_empty'               => 1,
    'hierarchical'             => 1,
    'taxonomy'                 => 'category',
$top_categories = get_categories($args);

I want $top_categories to return only those categories with products for current store

Thank you

share|improve this question
I don't seem to reach anywhere. I tried WP_Query(), get_terms(), get_categories. As said at first I can handle PHP but I don't know how WP internally works. – Vemman Jan 21 '14 at 10:51
OK Thought this will help someone. I used the site generatewp.com to craft my queries. Then implemented those in my custom frontend outside wordpress. The client wanted to display data from WP into another app. – Vemman Jan 25 '14 at 10:46
So is this fixed, or? – Matias Vad Mar 1 '14 at 8:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.