Query string URL parameter in wp-admin custom page ?
-
Hi,
I’m developping a specific plugin to display a custom page in a custom post-type (vehicle) which should show a table of sold vehicles and their details, by years.
In order to display the table corresponding to a desired year, I wanted to use a query string parameter (GET) in the page URL, so I could create a list of links with this “&sellyear=value” parameter for each existing years.
Ex : http:// localhost/lywebsite/wp-admin/edit.php?post_type=vehicle&page=eai_admin_vehicles_sales_submenu&sell_year=2018
What I tried is to declare a new query var in my plugin file :
add_filter( 'init', 'add_sellyear_query_var' ); function add_sellyear_query_var() { global $wp; $wp->add_query_var( 'sellyear' ); } $sellyear = get_query_var( 'sellyear' );But when I refresh the page, I got an error :
Fatal error: Uncaught Error: Call to a member function get() on null in C:\wamp\www\mywebsite\wp-includes\query.php
I’ve searched a lot on the web, but what I got is that, it seems not possible to use custom query string parameter in wp-admin… However the threads were pretty old (2012/2013) so I wonder if it is still impossible today ?
If it’s the case, what alternative can I try ?
If not, what is the correct way to use custom $_GET parameter in wp-admin page ?Thank you in advance,
N.
The topic ‘Query string URL parameter in wp-admin custom page ?’ is closed to new replies.