Viewing 7 replies - 16 through 22 (of 22 total)
  • Use in_array() to test to see if you have added a given meta-value to your array before adding it.

    Thread Starter Rakesh Raja

    (@rakeshraja)

    https://pastebin.com/UY2r8XF2

    If you look in the code and do that for me than great. I am not well versed in that.

    I am just a designer who copy paste codes from here and there and make things work ??

    Thread Starter Rakesh Raja

    (@rakeshraja)

    I got an idea.. can you tell me how to access values from database directly?

    no loop.. just a mysql code

    Thread Starter Rakesh Raja

    (@rakeshraja)

    Hi

    I have done it myself with pure mysql query..

    https://pastebin.com/QrdMBrhq

    can you tell me how can I achieve this by using $wpdb?

    regards

    hi rakeshraja,
    did you find solution in wpdb?
    I am searching for this.
    I am having custom field ‘city’ for multiple posts,
    and I need to display distinct city names with posts count,
    e.g:London (13)
    Paris (10)
    where 13 and 10 are number of posts means there are 13 posts having custom field ‘city’ value as ‘London’.
    what will be the query?

    $query = new WP_Query(array(‘post_type’=>’post’,’cat’=>’17’,’meta_key’=>’City’,’groupby’=>’meta_value’));
    did not worked.
    any help?
    how to use posts_groupby?

    rakeshraja, this may be a little late, but here’s a solution:

    Use the custom loop links that was sent by esmi, but add an array for all your returned custom field values, including ALL of your duplicate fields.

    After that loop is done, use array_unique function to return the unique value. Now, you have your unique values.

    A little PHP goes a LONGGGGG way, LOL!

    Bruce

Viewing 7 replies - 16 through 22 (of 22 total)
  • The topic ‘List unique value of custom field’ is closed to new replies.