GD search by post

This topic contains 12 replies, has 4 voices, and was last updated by  Guust 5 years, 4 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #458772

    Javier Vasquez
    Expired Member
    Post count: 100

    Hi,

    I have three kind of listing and in my homepage Im using two of yours GD search widget in two boxes. My problem is in both the selected listing by default is the same and I would like to set diferent listing for each one, for instance in one “places” and in the other one “events”.

    #458773

    Guust
    Moderator
    Post count: 29970

    I have asked a developer to have a look at your question, but is not possible by default.
    Thanks

    #458924

    Kiran
    Moderator
    Post count: 7069

    Hello Javier,

    Use following snippet and change widget id & post type accordingly.

    
    
    /*
     * Set search default post type.
     */
    function gd_snippet_widget_geodir_advance_search_args( $args, $instance ) {
    	if ( ( geodir_is_page( 'home' ) || geodir_is_page( 'location' ) ) && ! empty( $args['widget_id'] ) ) {
    		if ( $args['widget_id'] == 'geodir_advance_search-1' ) { 	// Change 1st widget id here.
    			$args['post_type'] = 'gd_event'; 						// Change to 1st post type.
    		}
    
    		if ( $args['widget_id'] == 'geodir_advance_search-2' ) { 	// Change 2nd widget id here.
    			$args['post_type'] = 'gd_place'; 						// Change to 2nd post type.
    		}
    	}
    
    	return $args;
    }
    add_filter( 'widget_geodir_advance_search_args', 'gd_snippet_widget_geodir_advance_search_args', 10, 2 );

    Thanks,
    Kiran

    #459093

    Javier Vasquez
    Expired Member
    Post count: 100
    This reply has been marked as private.
    #459115

    Guust
    Moderator
    Post count: 29970

    The widget ID can be found as indicated in the image. Right click on the search widget and choose “Inspect element”.

    #459126

    Alex Rollin
    Moderator
    Post count: 27815

    This feature is built into GDV2, such that the shortcode builder allows the choice of the default post type. Consider upgrading:

    https://wpgeodirectory.com/try-geodirectory-v2/

    #459183

    Javier Vasquez
    Expired Member
    Post count: 100

    Great! But how can I update keepin all the info I included until today?

    #459200

    Alex Rollin
    Moderator
    Post count: 27815
    #459218

    Javier Vasquez
    Expired Member
    Post count: 100

    THIS IS FOR GUUST

    I understant that each gedir_shortcode_location should have different ID. How can I modify “geodir_advance_search-1” to “geodir_advance_search-2”

    #459225

    Javier Vasquez
    Expired Member
    Post count: 100

    Alex I read the link but I think this use another version of geodirectory because it indicate “In the WordPress Backend visit GeoDirectory – Settings – General – Developer” but in my version there is no this option.

    #459238

    Guust
    Moderator
    Post count: 29970

    It is the code of the snippet you need to modify, not the code of the search widget.
    Everytime you add the search widget somewhere using a widget or shortcode, it will get a different geodir_advance_search-X
    You need to find that by looking at the source code, and then adjust the code Kiran gave.

    Thanks

    #459243

    Javier Vasquez
    Expired Member
    Post count: 100

    If I expected each to have a different name but it is not, for some reason they all have the same ID

    #459268

    Guust
    Moderator
    Post count: 29970

    I guess that is because you use a page builder.
    Try adding the GD Search using the shortcodes.

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket