• Hello everyone!


    I try to get URL parameter in the frontpage but I does not work, however when using parameter in custom page in works.

    E.g It works in example.com/custompage/?someParamater=nay , but does not work in example.com/?someParameter=yay

    I don’t use a simple _GET but WordPress functions (as I believe it is more secure? as I use it in get_posts later) The code I use:

    First I define a filter in the functions:

    function themeslug_query_vars( $qvars ) {
    $qvars[] = 'someParameter';
    return $qvars;
    }
    add_filter( 'query_vars', 'themeslug_query_vars' );

    Then I use it in my page as follows:

    get_query_var('someParameter')

    Thank you!

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Works for me, something else is going on. Works for a post archive front page anyway. With a static front page, supplying a query var in the base URL causes the post archive to be displayed instead of the static page. But the query var is still available even though the page otherwise has the wrong content.

    As a workaround, you could get the value from $_REQUEST['someParameter']

Viewing 1 replies (of 1 total)
  • The topic ‘Can not access URL parameter in the frontpage’ is closed to new replies.