HI,
I have a job website with custom posts 'Jobs' and related parent post 'Places'. These 'Places' are then connected with 'States'. So, 'State' posts become grandparents for 'Job' posts.
Now, I want to filter these job posts based on selected 'State' posts, so that I can show how many job posts are there in the 'States'. How to do this?
Here is the screenshot of single job post.
Thanks for your support. I have almost created the view with your help that I required. But one last thing I want to arrange the posts based on the 'Last date of application/Interview' (a custom field) and not as per the date of the post. Please help. Thanks.
No, it's not working. You can see the black box beside the post where days remaining to the last date of application is shown. It's not in any order while on my homepage you can see it in ascending order.
So, we have a view that filters for state, then places related to states and then jobs related to places. So we are looping through the top-level view state to bottom level view jobs.
So, for instance, For Maharastra state you have 9 places, so places view will loop through those 9 places one by one and display the jobs, which means the order will work for each loop instance of places view and it will display the order by restulst based on the places view loop.
Maharastra
- Place 1
--- post 1 - 15th oct
--- post 2 - 2nd oct
--- post 3 - 17th oct
- Place 2
--- post 4 - 7th oct
--- post 5 - 9th oct
--- post 6 - 5th oct
- Place 3
--- post 7 - 2nd oct
--- post 8 - 1st oct
--- post 9 - 5th oct
So, considering the above data, it should be displayed as:
Maharastra
- Place 1
--- post 2 - 2nd oct
--- post 1 - 15th oct
--- post 3 - 17th oct
- Place 2
--- post 6 - 5th oct
--- post 4 - 7th oct
--- post 5 - 9th oct
- Place 3
--- post 8 - 1st oct
--- post 7 - 2nd oct
--- post 9 - 5th oct
I do not have any way to offer you to sort the results becasue its actually sorting based on your date field but as the view is added as nested view due to that nature you do not able to sort it as you want.
Yah I understood your point. But let me give you one example (solution) provided by one of your support colleagues. This is a URL hidden link (15648) giving me results from Repeatable Field Groups (RFGs) of the posts accumulating from different Job posts according to the date order of the 'Last date of application/interview' for the jobs expired in last 7 days.
There are three views used here:
List Job Post Details posts (15646), Child view - expired-job-posts-within-7-days (15651) and Parent view - expired-job-posts-within-7-days (15650)
He has also used the following php code:
/*
*paginated view for weekly jobs
*/
add_filter( 'wpv_filter_query', function($query_args, $view_settings, $view_id){
if(in_array($view_id, array(15646, 16601, 15430,) ) ){ // view "List Job Post Details posts" ID
$query_args['orderby'] = 'post__in';
}
return $query_args;
}, 999, 3);
/**
* Include custom code
*/
My suggestion/query is can we take this route to generate the desired results? Thank you.
where:
- parent-view-expired-job-posts-within-7-days is retuning the IDs
So, above have two level strucure and now with your query you have three-level structure:
State -> places -> jobs
so you should try to follow the same structure as you used to display "Job Post Details (RFG)" but for three-level and check if you able to achieve your desired results by adding another wpv_query_filter hook.