Forums › Forums › Search & Filter Pro › Create “top 10” lists of CPTs grouped by ACF field value
Tagged: acf, cpt, top 10 posts with value, widget
- This topic has 13 replies, 3 voices, and was last updated 3 years, 12 months ago by Ross.
-
Anonymous(Private) October 30, 2020 at 10:12 am #264697
Hello,
I have a website with job openings. These jobs are a CPT (WP Job Manager), to which I regularly import jobs. The jobs have a number of ACF fields (such as company and location).What I am trying to achieve:
– Create a widget that will show me the top 10 companies with the most job openings (sorted by highest number first).
– Create a widget that will show me the top 10 locations with the most job openings.I am testing with S&F, but all I get is a list of companies with (0) behind it.
Can you tell me if what I’m trying to do is possible with S&F, and what I’m doing wrong?
Thank you very much!
Kind regards,
Boris HoekmeijerAnonymous(Private) November 2, 2020 at 11:38 am #264903Hi Trevor,
that helps, thanks. List is a lot shorter now :-).However, there are still some things not the way I would want them:
– I want to show only a top 10 of companies (those with the most job openings).
– Each item is now displayed with a checkbox. It should be a list with 1 through 10.Is this possible?
Trevor(Private) November 3, 2020 at 2:59 pm #265108ah yes, because this is the form, posts per page is not applied. You need to change the field display using this filter:
https://searchandfilter.com/documentation/action-filter-reference/#filter-input-object
And cut the array to just 10 ‘terms/labels’.
Anonymous(Private) November 4, 2020 at 7:53 am #265214Hi Trevor,
thanks for the link, but I’m not sure what I should do now.
I understand I have to enter the field name it concerns:function filter_function_name($input_object, $sfid) { if($input_object['name']=='_company_name') { //udpate this field before rendering } return $input_object; } add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);
But beyond that, I don’t know how to trim it down to 10 and how to sort them by number. I went through the code on the github page that is referred to, but that doesn’t bring me further. Can you help me get this right?
-
AuthorPosts