Support » Plugin: Content Visibility for Divi Builder » Querystring multiple values

  • Resolved tin_soldier

    (@tin_soldier)


    Hi,

    I’m using:

    isset( $_GET['state'] ) && $_GET['state'] === $state

    in a function to check for a query string ?state=TAS

    is there a way to check for multiple values ie; show content if state=TAS or state=VIC or state=WA

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jonathan Horowitz

    (@jhorowitz)

    Place this function in your theme’s functions.php:

    
    function has_get_request_value($name, $value) {
      return isset( $_GET[$name] ) && $_GET[$name] === $value;
    }
    

    In the Visibility field:

    
    has_get_request_value('state', 'TAS') || has_get_request_value('state', VIC') || has_get_request_value('state', 'WA')
    
    Thread Starter tin_soldier

    (@tin_soldier)

    Brilliant! Thanks Jonathan.

    Plugin Author Jonathan Horowitz

    (@jhorowitz)

    Anytime!

    Please let me know if there is anything else I can help you with!

    BTW, we are always looking for feedback; if you have a moment, please let us know how we are doing by leaving us a review!

    Thanks!

    Jon

    Thread Starter tin_soldier

    (@tin_soldier)

    Thanks. Have added a review and feedback.

    If I wanted to reverse that function and hide from multiple states, I thought this should work but it doesn’t.

    function hide_from_states($name, $value) {
      return isset( $_GET[$name] ) && $_GET[$name] != $value;
    }
    Plugin Author Jonathan Horowitz

    (@jhorowitz)

    Thanks for the feedback!

    Wrap everything in parentheses with an exclamation point before it.

    For example:

    
    !(has_get_request_value('state', 'TAS') || has_get_request_value('state', VIC') || has_get_request_value('state', 'WA'))
    

    meaning, not any of the three specified.

    Thread Starter tin_soldier

    (@tin_soldier)

    👍

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Querystring multiple values’ is closed to new replies.