• Resolved pgiesin

    (@pgiesin)


    Hi! I am trying to hide/show a section based on the value of a query parameter. What is the best way to extract this parameter as part of the Content Visibility plugin?

    Peter

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

    (@jhorowitz)

    Hi @pgiesin,

    Try isset( $_GET['q'] ) && $_GET['q'] === 'some value' where q is the parameter name and some value is the value it must equal.

    Hi,

    I tried this and received “critical error on your website”.

    My page was passed “?section=education”

    I tried giving the visibility plugin the boolean of:
    isset( $_GET[‘section’] ) && $_GET[‘section’] === ‘education’

    Any thoughts?

    Plugin Author Jonathan Horowitz

    (@jhorowitz)

    Hi @ununiform,

    No, that should be fine.

    Try adding that into a custom function like this in functions.php:

    function my_theme_is_requested_section($section) {
      return isset( $_GET['section'] ) && $_GET['section'] === $section;
    } 
    

    And calling it in the Content Visibility expression field as
    my_theme_is_requested_section('education')

    Thank you. That definitely helped.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Query Parameter’ is closed to new replies.