• Resolved Ashish27

    (@ashish27)


    Hi Eyal,
    First of all your plug in is great !
    I would like to seek help in case if I need to display the results on the basis of current location of user for one specific category. What sortcode must I use?
    Will there be the requirement of code changes ?
    Please assit.

    Thank you
    Regards
    Ashish

    https://wordpress.org/plugins/geo-my-wp/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Eyal Fitoussi

    (@ninjew)

    You are welcome Ashish.

    need to display the results on the basis of current location of user for one specific category.

    Do you mean to display results automatically on page load or by submitting a search form?

    Thread Starter Ashish27

    (@ashish27)

    Hi Eyal,
    Thank you for your quick response.

    Yes ! Your first part of understanding is correct. I would like to click on certain category and the results should come as per user’s current location for that particular category.

    I know that plug-in keeps track of user’s current location.
    Please assist if I need to add some code / sortcode Or to get some add on for this purpose.

    Thanks again.

    Regards
    Ashish

    Thread Starter Ashish27

    (@ashish27)

    Hi Eyal,
    Kindly assist. waiting for your helpful response ! Please let me know if I need to buy any of your add on if they have the same functionality.

    Thank you
    –Ashish

    Plugin Author Eyal Fitoussi

    (@ninjew)

    HI Ashish,
    Sorry for the delayed reply.

    I am still trying to better understand better what is that you are trying to accomplish as this part

    I would like to click on certain category and the results should come as per user’s current location for that particular category.

    gets me a bit confused.

    Do you want to create a form that will dynamically display results based on the visitor’s current location when he first visits the page? No search form submission involves in this form?
    and the results should be from a specific category?

    ( I apologize but it is 1:30 am right now and I am half a sleep 🙂 )

    Thread Starter Ashish27

    (@ashish27)

    Great seriousness towards profession Eyal !
    very impressed that you attended the query even at 1:30 AM. Great !!

    Do you want to create a form that will dynamically display results based on the visitor’s current location

    — correct. but not on “when he first visits the page?” but he clicks on certain category at the page.

    No search form submission involves in this form?

    — YES,we don’t want to submit any form.

    and the results should be from a specific category?

    — YES

    here is the exact scenario.

    Let me say we have a user accessing our website from New York. He finds that 8 categories are listed on our home page ( please refer http://bizgps.co.za/Example.jpg).
    so now user clicks on “Restaurant” >>He is redirected to the results page and he gets the results for all New York restaurants.
    Now he comes back next day and clicks on category “Hotel” >> again he is redirected to the results page and he gets the results for all New York “Hotels” and so on.

    so 3 step execution.
    User clicks on category >> Redirected to the page where specific sort code is placed >> Results for that particular category for user that time location.

    Hope I have cleared my Query this time. 🙂

    Many Thanks
    Regards
    Ashish

    Thread Starter Ashish27

    (@ashish27)

    Any Help mate ?

    Plugin Author Eyal Fitoussi

    (@ninjew)

    HI Ashish,
    Sorry for missing out your reply.

    Following the steps below you should be able to achieve what you described above:

    1) Create a page that will hold the GEO my WP search results. For example we’ll call it “Results”.

    2) You need to create the category links of the home page in a way that they will all link to this “Results” with the category slug pass via URL. So for example the link for “Hotel” category will look like http://www.businesslocator.com/results/?category=hotels

    3)

    • Create new ( or edit existing ) GEO my WP’s Posts Locator form.
    • Click on the “Search Form” tab and set the “Search form template” dropdown to “Disable search form”.
    • Click on “Page load results” tab, check the “Enable Page Load features” checkbox, choose the post type, check the “Display list of results” checkbox and set the rest of the filters as you wish.
    • click on the “Search Results” tab and set the search results as you wish.

    4) Edit the “Results” page you create above and add the shortcode of the form you just created ( [gmw form=”ID”] ) to the content of the page.

    5) Open the functions.php file of your theme/child theme and place there the script below:

    function gmw_filter_form_by_taxonomy_term( $args, $gmw ) {
    
    	// make sure we filter the correct form and that the category is in URL
           // chnage the value 5 to the form ID of the form you created
    	if ( $gmw['ID'] != 5 || empty( $_GET['category'] ) )
    		return $args;
    
    	// get the taxonomy term from URL
    	$term = $_GET['category'];
    
    	// pass the taxonomy term that we want to filter
           //Change "category" to the taxonomy you need to filter
    	$args = array(
    		array(
    			'taxonomy' => 'category',
    			'field'          => 'slug',
    			'terms'        => $term,
    		),
    	);
    
    	return $args;
    }
    add_filter( 'gmw_pt_tax_query', 'gmw_filter_form_by_taxonomy_term', 10, 2 );

    Follow the notes in the script to modify it based on your needs.

    That’s it. That I believe should work.

    Note that creating a “Results” page and linking all the categories to it is just one way. You can probably link the categories to the category archive page and make it work as well. You will need to place the form shortcode in the archive tempalte page and make it work by passing the category to the filter.

    Let me know if that helps.

    Thread Starter Ashish27

    (@ashish27)

    Thanks a lot Eyal,

    Solution is really wow. I have implemented it, this works perfectly fine. If there comes any issue in production run, I will get in touch.

    I would like to again praise your professionalism.

    Thank you once again Eyal !!

    Regards
    Ashish

    Plugin Author Eyal Fitoussi

    (@ninjew)

    You are very welcome. I am glad I could help.

    Just to let you know, for future issues/questions, that I am more active in GEO my WP official forum where I usually reply faster.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Results on the Basis of Specific Category’ is closed to new replies.