Forums › Global Maps › set category in shortcode
Tagged: Resume writing
- This topic has 11 replies, 5 voices, and was last updated 5 years ago by
Serge Ravet.
-
AuthorPosts
-
November 6, 2015 at 12:29 pm #48278
Digital Footprint
MemberHi,
Thanks for the great plugin. I was wondering, is it possible to filter by category in a form shortcode directly?
Thank you,
Tony
November 7, 2015 at 12:55 am #48314Eyal Fitoussi
MemberYou are welcome Tony, Thank you for the purchase.
I was wondering, is it possible to filter by category in a form shortcode directly?
I am not sure I understand, can you please explain what is that you would like to do?
Thank you.
November 8, 2015 at 11:19 pm #48813Digital Footprint
MemberHi Eyal,
Actually I’m using a global map form by shortcode like that :
[gmw form="1"]
And I wanted to know if there was a way of specifying a taxonomy term in the shortcode. For example :
[gmw form="1" include_terms="tourism"]
I tried to search for an answer in the docs but couldn’t find anything for that.
Thanks for your help.
November 11, 2015 at 12:28 am #48853Eyal Fitoussi
MemberUnfortunately, it is not possible at the moment.
Since the beginning, I developed GEO my WP forms builder to prevent the need to enter a bunch of shortcode attributes in order to set up a shortcode.
Is there a reason why you would like to enter the terms this way instead of setting them up directly in the form?
November 11, 2015 at 3:34 am #48864Digital Footprint
MemberHi Eyal,
Thanks for your response.
The thing is that I have a lot of different categories (50+) and I wanted to generate the maps on each page instead of having to create all of them manually. Is that possible in some way?
Thank you for your support.
November 26, 2015 at 2:39 am #49153Digital Footprint
MemberAny news?
November 26, 2015 at 9:41 am #49156Eyal Fitoussi
MemberHi,
Sorry for missing out your last reply.There is actually a way to do that.
You can set the term ID that you would like to display for the shortcode using a term_id attribute ( or any other attribute that you’d like to use ). For example [gmw form=”3″ term_id=”12″] ( showing only posts with term ID 12 for form ID 3.
Then place the below script in the functions.php file of your theme or child theme:
1234567891011121314function gmw_gmap_set_default_taxonomy( $gmw ) {// abort if term_id is not setif ( empty( $gmw['params']['term_id'] ) )return $gmw;$gmw['page_load_results']['taxonomies']['usage'] = 'include';$gmw['page_load_results']['taxonomies']['tt_id'] = array( $gmw['params']['term_id'] );return $gmw;}// change the value 3 to your form IDadd_filter( 'gmw_default_form_values_3', 'gmw_gmap_set_default_taxonomy' );The script will filter the map results based on the term_id you pass to the shortcode.
Let me know if that helps.
December 1, 2015 at 1:51 am #49223Eyal Fitoussi
MemberHi,
Just checking if you got to try the solution above and if it worked.December 5, 2015 at 9:08 pm #49349Eyal Fitoussi
MemberThis topic marked “Resolved” due to inactivity. If you wish to reply to this topic please change its status to “Not resolved” before replying.
November 23, 2016 at 9:41 am #55260ivollaire
MemberHi, Eyal. I’m trying to do the same thing as is mentioned in this thread. I want to have a page that will show a user only results from a certain category when a page loads using the auto-locator functionality. I have this code in my functions file:
1234567891011121314function gmw_gmap_set_default_taxonomy( $gmw ) {// abort if term_id is not setif ( empty( $gmw['params']['term_id'] ) )return $gmw;$gmw['page_load_results']['taxonomies']['usage'] = 'include';$gmw['page_load_results']['taxonomies']['tt_id'] = array( $gmw['params']['term_id'] );return $gmw;}// change the value 1 to the form IDadd_filter( 'gmw_default_form_values_1', 'gmw_gmap_set_default_taxonomy' );The shortcode I’m using is:
do_shortcode('[gmw form="1" term_id="65"]');
Where ‘term_id’ is the category that I want displayed. This doesn’t work. Am I doing something wrong? Any help would be great.
January 21, 2017 at 7:58 pm #55514Keshia Richmond
MemberThis reply has been marked as private.June 14, 2017 at 3:13 am #56041Serge Ravet
MemberHi, I’ve added the function in functions.php, changed ‘3’ to ‘1’ (my first form). Then in a page I’ve added:
[gmw form=”1″ term_id=”41″]
[gmw map=”1″]Yet nothing is filtered based on the taxonomy ID… Any idea what the problem could be?
Thx
-
AuthorPosts
The topic ‘set category in shortcode’ is closed to new replies.