The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

How to detect more then one value into a meta key? (2 posts)

  1. poliquinp
    Posted 4 years ago #


    I would like to know if it is possible to detect differents values from the same Meta Key into a query_post.

    I have a page that shows promotions depending on the values of the meta values.

    I got 2 types of products
    1. Clothes
    2. Shoes

    I want to get 3 types of possible promotions
    1. Both
    2. Clothes
    3. Shoes

    So if we follow this, I would like to show the promotion "X" in shoes and clothes if my meta value is "Both" only show the promotion "X" in shoes if in the same key I use "Shoes".

    Not sure if this is well explain.

    Here a part of code.

    $args = array(
    'post_type'	=> 'post',
    'meta_key'	=> 'concours_ou_promotion',
    'meta_value'	=> 'promotion',
    'meta_key'	=> 'Type de promotion',
    'meta_value'	=> 'Les deux',
    'meta_key'	=> 'Type de promotion',
    'meta_value'	=> 'VĂȘtements',
    'orderby'	=> 'ID',
    'order'		=> 'ASC',
    'numberposts'	=> 5

    You can see that I have tried to place the "Type de promotion" twice, but this is not working because the script search if it is in "Les deux" and in "VĂȘtements".

    I would like to detect if it is one or an other.

    Any help would be appreciate.

  2. poliquinp
    Posted 4 years ago #

    I didn't find a solution yet...

    So I have made the "easy way" by adding the custom field twice.

    Any help would be great to make the code better.

Topic Closed

This topic has been closed to new replies.

About this Topic