add toast local SEO Data
Add Yoast Local SEO Data to a Location Page using PHP: In this article, I am going to teach you how to add Yoast Local SEO Data to a Location Page. By adding this data, your location pages will rank higher on Google and other search engines.
Web development is sometimes (always) challenging; we’ve found the Yoast Local SEO shortcodes can be limiting at times. We still use their data but have to pull it into very specific places on the site. The WordPress function` get_options()` is how you go about getting the local business data when using a single location (doesn’t work with multiple locations).
The major reason for using the Yoast Local SEO plugin is because the output is on point with schema and HTML markup. If you use the above and don’t take into account schema and html, then you will miss out on one of the best benefits of this plugin. That’s how Google determines position in its Local rankings results.
Step 1: Get Local SEO Data from the Database
Yoast stores your single location data as a serialized array in the options table for WordPress.
In order to retrieve that data, set a custom variable as an array:
1 | $wpseo_local = get_option( 'wpseo_local' ); |
Need help with your News Website SEO Strategy? Schedule a free strategy session with the 702 Pros team.
Get a Free Digital Marketing Quote!
Give us a call at (702) 904-4262
Powered by OnSago
Step 2: Find What Data You Need from the Database
(Add Yoast Local SEO Data to a Location Page using PHP) After the $wpseo local variable is setup as an array storing all of the Yoast Local SEO data, it has been really easy to use that information with any of the following fields:
Below is a list of PHP calls to get you started in the right direction. Feel free to copy the information below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | <?php echo $wpseo_local [ 'location_name' ]; ?> <?php echo $wpseo_local [ 'business_type' ]; ?> <?php echo $wpseo_local [ 'location_address' ]; ?> <?php echo $wpseo_local [ 'location_address_2' ]; ?> <?php echo $wpseo_local [ 'location_city' ]; ?> <?php echo $wpseo_local [ 'location_state' ]; ?> <?php echo $wpseo_local [ 'location_zipcode' ]; ?> <?php echo $wpseo_local [ 'location_country' ]; ?> <?php echo $wpseo_local [ 'location_phone' ]; ?> <?php echo $wpseo_local [ 'location_phone_2nd' ]; ?> <?php echo $wpseo_local [ 'location_fax' ]; ?> <?php echo $wpseo_local [ 'location_email' ]; ?> <?php echo $wpseo_local [ 'location_url' ]; ?> <?php echo $wpseo_local [ 'location_vat_id' ]; ?> <?php echo $wpseo_local [ 'location_tax_id' ]; ?> <?php echo $wpseo_local [ 'location_coc_id' ]; ?> <?php echo $wpseo_local [ 'location_price_range' ]; ?> <?php echo $wpseo_local [ 'location_coords_lat' ]; ?> <?php echo $wpseo_local [ 'location_coords_long' ]; ?> <?php echo $wpseo_local [ 'locations_slug' ]; ?> <?php echo $wpseo_local [ 'locations_label_singular' ]; ?> <?php echo $wpseo_local [ 'locations_label_plural' ]; ?> <?php echo $wpseo_local [ 'locations_taxo_slug' ]; ?> <?php echo $wpseo_local [ 'business_image' ]; ?> <?php echo $wpseo_local [ 'opening_hours_monday_from' ]; ?> <?php echo $wpseo_local [ 'opening_hours_monday_to' ]; ?> <?php echo $wpseo_local [ 'opening_hours_monday_second_from' ]; ?> <?php echo $wpseo_local [ 'opening_hours_monday_second_to' ]; ?> <?php echo $wpseo_local [ 'opening_hours_tuesday_from' ]; ?> <?php echo $wpseo_local [ 'opening_hours_tuesday_to' ]; ?> <?php echo $wpseo_local [ 'opening_hours_tuesday_second_from' ]; ?> <?php echo $wpseo_local [ 'opening_hours_tuesday_second_to' ]; ?> <?php echo $wpseo_local [ 'opening_hours_wednesday_from' ]; ?> <?php echo $wpseo_local [ 'opening_hours_wednesday_to' ]; ?> <?php echo $wpseo_local [ 'opening_hours_wednesday_second_from' ]; ?> <?php echo $wpseo_local [ 'opening_hours_wednesday_second_to' ]; ?> <?php echo $wpseo_local [ 'opening_hours_thursday_from' ]; ?> <?php echo $wpseo_local [ 'opening_hours_thursday_to' ]; ?> <?php echo $wpseo_local [ 'opening_hours_thursday_second_from' ]; ?> <?php echo $wpseo_local [ 'opening_hours_thursday_second_to' ]; ?> <?php echo $wpseo_local [ 'opening_hours_friday_from' ]; ?> <?php echo $wpseo_local [ 'opening_hours_friday_to' ]; ?> <?php echo $wpseo_local [ 'opening_hours_friday_second_from' ]; ?> <?php echo $wpseo_local [ 'opening_hours_friday_second_to' ]; ?> <?php echo $wpseo_local [ 'opening_hours_saturday_from' ]; ?> <?php echo $wpseo_local [ 'opening_hours_saturday_to' ]; ?> <?php echo $wpseo_local [ 'opening_hours_saturday_second_from' ]; ?> <?php echo $wpseo_local [ 'opening_hours_saturday_second_to' ]; ?> <?php echo $wpseo_local [ 'opening_hours_sunday_from' ]; ?> <?php echo $wpseo_local [ 'opening_hours_sunday_to' ]; ?> <?php echo $wpseo_local [ 'opening_hours_sunday_second_from' ]; ?> <?php echo $wpseo_local [ 'opening_hours_sunday_second_to' ]; ?> <?php echo $wpseo_local [ 'sl_num_results' ]; ?> <?php echo $wpseo_local [ 'unit_system' ]; ?> <?php echo $wpseo_local [ 'map_view_style' ]; ?> <?php echo $wpseo_local [ 'address_format' ]; ?> <?php echo $wpseo_local [ 'default_country' ]; ?> <?php echo $wpseo_local [ 'show_route_label' ]; ?> <?php echo $wpseo_local [ 'custom_marker' ]; ?> <?php echo $wpseo_local [ 'api_key_browser' ]; ?> <?php echo $wpseo_local [ 'api_key' ]; ?> <?php echo $wpseo_local [ 'location_taxo_slug' ]; ?> <?php echo $wpseo_local [ 'location_timezone' ]; ?> |
Step 3: Setting the Time Format Correctly
As a standard, your business opening hours will be stored in military time (ie, 0900 is 9:00 am, and 1300 is 1:00 pm). You will most likely want to convert them from military to a 12-hour format.
You can easily do so by using a time variable like the one below:
1 | <?php echo date ( "g:i a" , strtotime ( $wpseo_local [ 'opening_hours_sunday_from' ])); ?> |
Step 4: Removing Special Characters from Phone Numbers
Most people are familiar with using the anchor tag for a phone number, the typical format is as follows:
1 | < a href = "tel:7029044262" >(702) 904-4242</ a > |
However, when using Yoast fields, the inherit data will automatically pull special characters into the HTML (ie: ‘(‘ and ‘-‘) which will mess with your HTML code a bit, ultimately making your phone links not work correctly.
Example below:
1 | < a href = "tel: >(702) 904-4242</ a > |
To fix this, you’ll u need to use a regex call to strip and remove unwanted characters from the link.
In PHP this is called a preg_replace action and looks like this:
1 | <?php echo preg_replace( "/[^0-9,.]/" , "" , $wpseo_local [ 'location_phone' ]); ?> |
I hope this article has helped you in creating PHP data calls for Local SEO data from Yoast. If you have any questions, please leave a comment below. This guide is also available and written as a blog post. You can find the blog post here. Check out the Multi-location Yoast SEO Guide to learn how to add data for more than one location. Step-by-Step tutorial you will need to edit a few different files in order to add Yoast SEO data to your location page.
Need help with your News Website SEO Strategy? Schedule a free strategy session with the 702 Pros team.
Get a Free Digital Marketing Quote!
Give us a call at (702) 904-4262
Powered by OnSago
Common Yoast Local SEO Questions:
- Q: What does Yoast local SEO do?
A: The Local SEO plugin helps you to embed Google Maps and automatically show your up-to-date opening hours. All you need is a Google account and no technical knowledge.
- Q: Does Yoast SEO Really Work?
A: Yes, Yoast SEO works! It’s the most popular plugin on WordPress, with over 11 million downloads and a 5-star rating. You don’t stay that popular for so long if you don’t have something to show for it 🌟
- Q: Is Yoast SEO free worth?A: Is Yoast SEO Premium worth it? No, it is not. The multiple focus keywords feature is pretty much useless, redirects can be setup using free redirect plugins, and nothing in Yoast Premium directly improves your SEO. It’s not worth $99/year.
- Q: What is better than Yoast SEO?
- Q: What is the difference between organic SEO and local SEO?
- Q: How much is local SEO?
- Q: What is meant by local SEO?
- Q: How does local SEO work?
- Q: How can I improve my local SEO?
- Q: What is local SEO for small business?
- Q: What is White Hat SEO?
- Q: What are the types of SEO?
- Q: What is organic SEO?
- Q: What is off-page SEO?
- Q: How do you do eCommerce SEO?
- Q: What is mobile SEO?
Other Interesting Reads:
- Guide to SEO News, Trends, Expert Analysis & How-To
- Strategic SEO Tips for Optimizing News Sites
- How to Use Google My Business to Help Your Small Local Business Grow
- Discover These Top Marketing Trends in 2022
- The Complete Guide to Website Maintenance
- The Complete Guide to Website Hosting and How it Can Help You Build a Successful Business
- What are the 4 Most Effective Types of Advertising and How Can You Use Them?
- How to Create a Shipping Label for Your Merchandise in Photoshop
- Is web design still in demand? Modern Design Trends in Web Design and How a Web Designer Can Help
- How to Increase Website Conversion Rate in 2022
- Cyber Security Challenges For Your Business
- 10 Inbound Marketing Tips And Tricks You Need To Know
Related Terms:
- what is SEO social media
- social media strategies to boost SEO
- how to incorporate social media into SEO strategy
- SEO tools for social media
- best social media platforms for SEO
- SEO for a social media course
- SEO for social media LinkedIn
- social signals google ranking
- social media backlinks SEO
- sites for SEO
- what is SEO in digital marketing
- social media profile ranking
- social media optimization, Forbes
- SERP social media
- SEO social media optimization
- best SEO social media sites
- SEO marketing
Other Considerations:
- Check out our SMM by 702 Pros
- Social Media Marketing Las Vegas, NV
- Social Media Marketing Honolulu, HI
- Digital Marketing Key West, FL
- Digital Marketing El Cajon, CA
- Digital Marketing Kent, WA
- Digital Marketing Durango, CO
- Social Media Marketing Bar Harbor, ME
- SEO Jacksonville, FL
- SEO Sonoma, CA
- See How We Help Businesses with Web Design Albuquerque, NM
- #1 Web Design Santa Rosa, CA
- Top-Rated Marketing Agency in Santa Monica, CA
- Learn How SEO West Palm Beach, FL Has Changed with 702 Pros Digital Marketing and SEO
- Consider Spearbrand for your next marketing campaign!
add toast local SEO Data
add toast local SEO Data
add toast local SEO Data
add toast local SEO Data
add toast local SEO Data
add toast local SEO Data
add toast local SEO Data
add toast local SEO Data
add toast local SEO Data
add toast local SEO Data
add toast local SEO Data
add toast local SEO Data
add toast local SEO Data
add toast local SEO Data
add toast local SEO Data