Public Ticket #1147196
change the order in which the info appears in a business listing


  • Aina83 started the conversation

    Hi, I almost finished my business directory, just a thing please:

    when you click a busniess listing can you change the order in which the info appears? For example to have “contact” information right after “description” and have the map at the end, not in the middle? if so, How?


  •  2
    asidamedia replied

    Hey you can change the order by adding this code into your functions.php in your child-theme:

    add_filter( 'inventor_listing_detail_sections', function( $sections, $post_type ) {
        return array(
            'overview'      => esc_attr__( 'Overview', 'inventor' ),
            'description'   => esc_attr__( 'Description', 'inventor' ),
            'contact'       => esc_attr__( 'Contact', 'inventor' ),
            'opening_hours' => esc_attr__( 'Opening Hours', 'inventor' ),
            'social'        => esc_attr__( 'Social connections', 'inventor' ),
            'location'      => esc_attr__( 'Location', 'inventor' ),
            'gallery'       => esc_attr__( 'Gallery', 'inventor' ),
            'video'         => esc_attr__( 'Video', 'inventor' ),
            'food_menu'     => esc_attr__( 'Meals And Drinks', 'inventor' ),
            'faq'           => esc_attr__( 'FAQ', 'inventor' ),
            'comments'      => null,
            'report'        => null
    }, 10, 2 );

    You can also change the code for different orders..

  • Aina83 replied


  •  4
    FXZOO replied

    is there any easier way ? I dont know how to do it or maybe you can show it step by step?

    I would like to have review section  at the top

  •  89
    Erik replied

    Hi. It's the easiest way actually. Put the code into the functions.php of your child theme and you are done.

  •  4
    FXZOO replied

    yeah, thanks , I managed to do it

  •  2
    Webink74 replied


    Is it possible to add another filter on this filter to specify different sections orders following the kind of listing types, categories or final listings ?

    Many reasons, let me explain : 

    1. If there is a category where the main detail is the "Opening hours" section then it's natural to display it first. 
    2. If there is an other category where the main detail is the "Gallery" section, we need to create an new specific order where the gallery will be above.
    3. If, a user registers in one of those categories, but he finally judges that it's better for him to display the "Map" first instead of the gallery/hours, then he contacts the admin who creates a specific details order for its listing.

    If not already available, this behavior would make sense as we could suit a new level of customization and cover more precisely the needs of potential customers.

  •  89
    Erik replied

    It is actually already possible. There is a $post_type argument available for the WP filter. You can use it like this:

    add_filter( 'inventor_listing_detail_sections', function( $sections, $post_type ) {   
        if ( $post_type == 'car' ) {
           // return sections for car listing type
        if ( $post_type == 'hotel' ) {
           // return sections for hotel listing type
        if ( $post_type == 'pet' ) {
           // return sections for pet listing type
        return $sections;
    }, 10, 2 );
  •  2
    Webink74 replied

    Perfect, thank you. Is this also works for any single/specific listing ?

    For instance, in the same way than we use : if ( $post_type == 'cars' ), can we add the post id/title :

    if ( $post_type == 'cars' && $p == 'infiniti-q50' )

  •  89
    Erik replied

    You can use global post id in your condition using get_the_ID() function from WordPress API: