2 letter state abbreviations
This topic contains 12 replies, has 3 voices, and was last updated by Lance Sampson 8 years, 7 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
April 10, 2017 at 8:27 pm #372871
I need to be able to show 2 letter state abbreviations for my listings here in the United States. I have two ideas but not really sure which would be better.
1. Is there any way to have a “state abbreviation field” that is manually entered by the user when the listing is created and have some sort of function that uses an “if” statement or sorts that says. If the state abbreviation fields is not empty then use that in the “region” field, if not then use what is automatically inputted for the region.
Or…
2. I have used 51 GD categories for the state abbreviations for all 51 states in the United States. For example: TX for Texas. I know that I can use the %%ct_gd_placecategory%% to add the state abbreviations to the meta title and description for SEO purposes. I just need to know how to change out the “region” field with the “category” field in the address so it shows the abbreviations in the address for the details, listings and search pages?
Any help would be greatly appreciated.
Thanks in advance.
April 11, 2017 at 1:17 pm #372932Hi Lance,
Where exactly do u need to show this, just in the address?
Stiofan
April 11, 2017 at 3:45 pm #372965Hi Stiofan
Yes, just the address.
Thanks
April 11, 2017 at 4:55 pm #372993Here is a short snippet that will do it for the first two, u just need to add the rest as the same
add_filter('geodir_custom_field_output_address','_my_short_state_geodir_cf_address',11,3); function _my_short_state_geodir_cf_address($html,$location,$cf){ // we add the >NAME< so we only replace the regions and not the region name in a street address. $state_long = array( ">Alabama<", ">Alaska<", ); // we add the >NAME< so we only replace the regions and not the region name in a street address. $state_short = array( ">AL<", ">AK<", ); $html = str_replace($state_long,$state_short,$html); return $html; }Stiofan
April 11, 2017 at 5:24 pm #373000Stiofan,
I added this to the code snippets plugin but it does not seem to be translating.
Any suggestions?
Thanks
April 13, 2017 at 1:43 pm #373333Hi Stiofan,
I added the code but its not working. Other than adding the code to the snippets plugin, was there anything else I needed to change?
Best Regards,
April 13, 2017 at 2:13 pm #373340Seems to work fine for me on my test site, if u provide wp-admin details in a private reply i will check your settings.
Stiofan
April 13, 2017 at 3:02 pm #373347This reply has been marked as private.April 13, 2017 at 7:10 pm #373380The snippet provided by Stiofan will work in the sidebar address.
You already have 3 snippets to modify the address formats in several location so we will need to adapt the script to your situation.
Stiofan will let you know how to correct that asap.
Thanks
April 13, 2017 at 7:25 pm #373387Sounds great.
I thank you and Stiofan for all your support!
April 14, 2017 at 9:36 am #373460Check now, “address format on details page” and “State abbreviations”
Stiofan
April 14, 2017 at 2:58 pm #373528Still no abbreviations
Lance
April 14, 2017 at 3:01 pm #373529Stiofan
Nevermind, I was looking at the wrong state. I was waiting until it worked so i could add the rest.
Thank you so much for that code. Its gonna help more than you know.
Your the King!
Best Regards,
Lance -
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket