Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Get ID of post or page ASP shortcode is on and use in asp_query_args meta filter
This topic contains 2 replies, has 2 voices, and was last updated by Menzer92 3 years, 2 months ago.
- AuthorPosts
- January 22, 2020 at 4:10 pm #25398
Hi I have an ajax search pro shortcode inserted in on a post page and I need to grab the post page id variable and insert it in the meta value below, is there a way to do this…. I assume this would be done via javascript code/variable but I cannot find the code for it. I have inserted the code I am working with. Everything filters nicely if I manually enter the post ID but I would like it to be the post variable. I tried global $post, get_query_object_id(), get_the_ID() but nothing works
function asp_query_args_change($args, $search_id) { if($search_id == '4'){ $args['post_meta_filter'] = array( array( 'key' => '_EventOrganizerID', 'value' => 41069, <------- <strong>This is the post page the shortcode is inserted on</strong> 'operator' => '=' ), ); } return $args; }
January 22, 2020 at 6:50 pm #25404Hi!
Sure, this variable should hold the current page ID:
Best,$args['_page_id'];
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 22, 2020 at 8:56 pm #25412You are the Boss!!! Thank you soooo much!!!!
- AuthorPosts
You must be logged in to reply to this topic.