Support

Account

Forum Replies Created

  • Thanks https://support.advancedcustomfields.com/forums/users/hube2/
    This worked but was still not entirely the solution as I found I had yet another custom field to check against..and applying the way you solved this I thought I had it…

    What I need is something like this but it isn’t working..

    Pseudo code

    IF all are relation are true (AND)
    AND
    sale price <300
    AND
    either status NOT EXISTS
    OR
    either status =”
    AND
    either sp-alt NOT EXISTS
    OR
    either sp-alt =”

    code..` ‘meta_query’ => array(
    ‘relation’ => ‘AND’,
    //AND
    array(
    ‘key’ => ‘sale_price’,
    ‘value’ => 300000,
    ‘type’ => ‘NUMERIC’,
    ‘compare’ => ‘<‘
    ),
    //AND
    array(
    ‘relation’ => ‘OR’,
    array(
    ‘key’ => ‘status’,
    ‘compare’ => ‘NOT EXISTS’
    ),
    array(
    ‘key’ => ‘status’,
    ‘value’ => ”,
    ‘compare’ => ‘=’
    )
    ),
    //AND
    array(
    ‘relation’ => ‘OR’,
    array(
    ‘key’ => ‘sp-alt’,
    ‘compare’ => ‘NOT EXISTS’
    ),
    array(
    ‘key’ => ‘sp-alt’,
    ‘value’ => ”,
    ‘compare’ => ‘=’
    )
    ),`

    I get that we need to check OR for each field as it can be one or the other or at least one if it is both..

    I only want to see an item if it is less than 300 and doesn’t have a value in any of the fields sp-alt or status..if anything is in either of those fields I DON’T want to show the item. My logic seems right after you helped me get this far.

    TY anyway I am going to play more..

  • Thanks it gave me more to experiment with but even then I still can’t seem to get it right I have this if anyone knows why..

    array(
          'key'		=> 'sale_price',
    			'value'		=> 300000,
    			'type'		=> 'NUMERIC',
    			'compare'	=> '<'
        ),
    		array(
    			'key'		=> 'status',
    			'value'		=> '',
    			'compare'	=> 'EXISTS'
    		)

    So I am saying nothing exists sort of thing..TY

Viewing 2 posts - 1 through 2 (of 2 total)