Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author TC.K

    (@wp_dummy)

    You can try set the pre_get_post priority to more than 1000, as the plugin uses priority of 1000

    Thread Starter Aurélien Denis

    (@maigret)

    Thanks for your reply. If I do this, the request is no more working…

    Here is my piece of code :

    https://pastebin.com/iBwtFEfu

    Plugin Author TC.K

    (@wp_dummy)

    Because the query is overrides by your meta query.
    Another way is add the hidden field into the search form, by using awpqsf_addextra_cmf() hook.

    Eg.

    add_filter(‘awpqsf_addextra_cmf’,’hidden_cmf_field’,”,3);
    function hidden_cmf_field($newcmf, $i,$id){
    $excludekey = ”;//your exclude meta field key
    $excludecompare = ‘2’;// 2 is the reference number for “!=”
    $excludevalue = ”;//the meta value that you need to compare

    echo ‘<input type=”hidden” name=”cmf[‘.$i.’][metakey]” value=”‘.$excludekey.'”>’;
    echo ‘<input type=”hidden” name=”cmf[‘.$i.’][compare]” value=”‘.$excludecompare.'”>’;
    echo ‘<input type=”hidden” name=”cmf[‘.$i.’][value]” value=”$excludevalue”>’;
    }

    Thread Starter Aurélien Denis

    (@maigret)

    Ok I did this:

    add_filter('awpqsf_addextra_cmf','hidden_cmf_field','',3);
    function hidden_cmf_field($newcmf, $i,$id){
    $excludekey = 'Photos_0';//your exclude meta field key
    $excludecompare = '2';// 2 is the reference number for "!="
    $excludevalue = '';//the meta value that you need to compare
    
    echo '<input type="hidden" name="cmf['.$i.'][metakey]" value="'.$excludekey.'">';
    echo '<input type="hidden" name="cmf['.$i.'][compare]" value="'.$excludecompare.'">';
    echo '<input type="hidden" name="cmf['.$i.'][value]" value="$excludevalue">';
    }

    But where should I put the form ID?

    Thread Starter Aurélien Denis

    (@maigret)

    My bad it seems to works fine. The last line was missing quotes ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Exclude results of certain custom field value’ is closed to new replies.