Timeline for WordPress search results with Ajax, get_post_type() not working
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 27, 2017 at 19:59 | vote | accept | Bob | ||
Mar 27, 2017 at 19:58 | answer | added | Laxmana | timeline score: 0 | |
Mar 27, 2017 at 19:51 | comment | added | Bob | Thank you very much @Laxmana. If you wish, you can post your comments as an answer so I can accept it as the correct answer. In any case, thanks! | |
Mar 27, 2017 at 19:07 | comment | added | Laxmana |
When executing an AJAX request through wp-admin/admin-ajax.php WordPress executes only the code registered to that request. So query vars etc are not initialized and that's why get_search_query() is not working. The flow of AJAX is different from the normal one.
|
|
Mar 27, 2017 at 17:46 | comment | added | Bob |
Thank you for your reply. As I mentioned, these were secondary ideas. In any case, you're right - it works with POST :). Any idea as to why get_search_query() isn't working?
|
|
Mar 27, 2017 at 15:44 | comment | added | Laxmana |
$_GET['s'] will not work for two reason. Firstly you make a POST request and not a GET request and secondly there is no variable with name s in your request.
|
|
Mar 27, 2017 at 14:55 | history | asked | Bob | CC BY-SA 3.0 |