WordPress get_query_var()

后端 未结 3 1718
闹比i
闹比i 2021-02-07 12:10

I am busy developing a WordPress application and I need to be able to pass url parameters using WordPress functions. I use add_query_arg() function to add a url par

3条回答
  •  半阙折子戏
    2021-02-07 12:37

    If you check out the Codex, you'll see you actually need to do some fiddling to get WP to start reading your query string.

    Codex (under Custom Query Vars)

    Excerpt:

    In order to be able to add and work with your own custom query vars that you append to URLs (eg: "mysite com/some_page/?my_var=foo" - for example using add_query_arg()) you need to add them to the public query variables available to WP_Query. These are built up when WP_Query instantiates, but fortunately are passed through a filter 'query_vars' before they are actually used to populate the $query_vars property of WP_Query.

提交回复
热议问题