I'm having an issue with the order WordPress is loading page templates and
front-page.php which has
$_POST['sort-by'] allowing users to sort posts using a drop-down menu.
It's simple enough and works just fine. Now comes the part where I have the ability to "Load more posts" which uses
wp_ajax_nopriv and a function in
functions.php to grab the additional posts with an offset of the number of posts shown by default. My AJAX query works just fine, but I'm unable to grab the
$_POST data from the
front-page.php template within'
functions.php to properly sort the posts fetched by the AJAX.
I thought it'd be as simple as just including my same
$_POST values within'
functions.php so it would use the proper sorting+meta_key, but no matter what I do including attempting to assign a separate variable to
$GLOBALS containing the
$_POST, I can not for the life of me get it to get the values set in
functions.php so it will sort it properly when calling
I'm assuming this has to do with
functions.php being loaded BEFORE
front-page.php within' WordPress. I'm not sure if there's an
add_action(); of some kind that would allow me to fix my issue here or how I should go about getting it to work as intended. I know it has to be possible though.
EDIT: Here is the function I'm trying to get
$_POST data for from my page template