Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Results field issues
This topic contains 4 replies, has 2 voices, and was last updated by Ernest Marcinko 1 year ago.
- AuthorPosts
- March 8, 2022 at 5:01 pm #37110
Hi there! I am having some trouble with the results field on the linked page here: https://newdevpm.wpengine.com/attorneys/
We are wanting all attorneys to be displayed upon page load. Right now there are only 37 displaying, when there should be just under 70. We would also like them to be displayed in A-Z alphabetical order by last name.
Thank you for your help!
March 9, 2022 at 11:06 am #37122Hi,
Thank you for the details!
So, the main issue here was, that there were number of category exclusions/inclusions set, but it just caused more issues – because the attorneys are not actually in the “attorneys” category, some of them are in sub-categories, some of them not even categorized.
The easiest, best and fastest solution to this was adding a custom code to the function.php file in your theme directory:
add_filter( 'asp_query_args', 'asp_include_only_parent_ids', 10, 2 ); function asp_include_only_parent_ids( $args, $id ) { /** * Enter the post/cpt prent IDs here. The results will be * limited to objects with these parent IDs. */ $ids = array(2321); /** * Search instance IDs you want this code to apply on. */ $search_ids = array(3); // -------------------------------------------------- // -------------------------------------------------- // -- !! Do not change anything below this line !! -- // -------------------------------------------------- if ( in_array($id, $search_ids) ) $args['post_parent'] = $ids; return $args; }
This code will force the attorneys search (id=3) to only show items, where the parent page is the “Attorneys” page (id=2321), and that is it.
Please keep a copy of this code, as a theme update may remove it automatically. I hope this helps!
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 9, 2022 at 11:10 am #37124And I forgot the ordering, for that I simply changed it by title descending: https://i.imgur.com/y2LoSSp.png
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 9, 2022 at 6:29 pm #37126Oh wow, Thank you so much!! Just one more thing…can the Attorneys be ordered by last name instead of by first name? I set a custom field for last name on the attorney profile pages with the intention of being able to do that if possible.
I really appreciate your help!
March 10, 2022 at 7:53 am #37131Sure, use the custom field ordering as string here: https://i.imgur.com/bl6LJVQ.png
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.