Results field issues

This topic contains 4 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 6 months, 2 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #37110
    randyl43
    randyl43
    Participant

    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!

    #37122
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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 :)


    #37124
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    And 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 :)


    #37126
    randyl43
    randyl43
    Participant

    Oh 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!

    #37131
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Sure, 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 :)


Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.