Client Revenue$96,120,614

How to Add Yoast Local SEO Data with PHP to a Location Page

Updated September 26, 2022
Add Yoast Local SEO Data to a Location Page using PHP | 702 Pros

Content Key

Share this Post :

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!
Want to talk now?
Give us a call at (702) 904-4262

Powered by OnSago

Rank #1 on google with 702 pros seo - digital
Rank #1 on google with 702 pros seo

 

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">(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!
Want to talk now?
Give us a call at (702) 904-4262

Powered by OnSago

Rank #1 on google with 702 pros seo - digital
Rank #1 on google with 702 pros seo

 

Common Yoast Local SEO Questions:

  1. 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.

  2. 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 🌟

  3. 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.
  4. Q: What is better than Yoast SEO?
  5. Q: What is the difference between organic SEO and local SEO?
  6. Q: How much is local SEO?
  7. Q: What is meant by local SEO?
  8. Q: How does local SEO work?
  9. Q: How can I improve my local SEO?
  10. Q: What is local SEO for small business?
  11. Q: What is White Hat SEO?
  12. Q: What are the types of SEO?
  13. Q: What is organic SEO?
  14. Q: What is off-page SEO?
  15. Q: How do you do eCommerce SEO?
  16. Q: What is mobile SEO?

Other Interesting Reads:

Related Terms:

Other Considerations:

Join our email list for marketing strategies, website tips and ux improvements, and business insights.

About the Author

Justin is a local marketing expert with over 15 years of experience creating brand recognition around digital strategies.

Leave a Reply

Get a Free Digital Marketing Quote!
Want to talk now?
Give us a call at (702) 904-4262

Powered by OnSago

More Great Posts

Get a Free Digital Marketing Quote!
Want to talk now? Give us a call at (702) 904-4262

Powered by OnSago

Advertise with us

Join our advertising network to grow your business. Call +1(702) 904-4262

Rank #1 on Google with 702 Pros | Sidebar Advertisement | 702 Pros SEO
Sponsored
34.99 WordPress Updates | WordPress Support by 702 Pros
Sponsored
Best Top #1 How to Add Yoast Local SEO Data with PHP to a Location Page Las Vegas, NV | How to Add Yoast Local SEO Data with PHP to a Location Page Agency | Justin Young, US Air Force Veteran and CEO of 702 Pros
Justin Young Signature - 702 Pros

Justin YoungCEO of 702 Pros

I'm Justin Young
Air Force Veteran, Founder and CEO of 702 Pros.

I lead our team to grow our client’s businesses with smart and innovative web design and digital sales systems. I treat every business like it were my own, giving each the attention it deserves. In short, our experts will focus on delivering the best results producing the greatest ROI for your business.

Let’s talk about your business!

VOSB CVE AWARD

Our How to Add Yoast Local SEO Data with PHP to a Location Page Agency will work hard to make sure your business succeeds online

Our How to Add Yoast Local SEO Data with PHP to a Location Page experts are waiting to build your business credibility like never before. Let our Las Vegas NV team help grow your brand with digital marketing & WordPress management solutions, built around producing the highest return on your business investment.

2021 Winner
Best Web Design Agency in Las Vegas, NV
2021 Winner
Best Digital Marketing Agency in Las Vegas, NV
2021 Winner
Best SEO Agency in Las Vegas, NV

Deals on Web Design Pricing in Las Vegas, NV

Hurry our web design deals in Las Vegas, NV will only last for a limited time only. Our team of Las Vegas, NV web designers have the experience and knowledge to get your business off to the best start possible or improve your business presence with SEO Las Vegas, NV, digital marketing Las Vegas, NV, web support and website hosting Las Vegas, NV

20% off Web Design Deal Ends Soon!

Days
Hours
Minutes
Seconds

Grow with the Pros

Let us know about you to get started.

OnCapthcaPrivacy · Terms

Want to talk now? Give us a call at (702) 904-4262

Powered by OnSago

Ready to speak with a marketing expert?

Call our team @
+1(702)904-4262

Our Pros have your back with award-winning design and marketing, Including proven systems focused on producing the best return on your investment.

702 Pros is veteran-led design by Justin Young—Air Force Veteran and Digital Marketing Las Vegas, NV Authority.

2021 Winner
Best Web Design Agency in the United States
702 Pros Landscape Logo Vector - with url and grow with digital catchphrase
Google Partners
Meta Business Partners
Inc 5000

FAQs

There are definitely benefits associate with hiring a local website hosting provider over a large hosting provider like Godaddy. One, you have a clear company
There are definitely benefits associate with hiring a local website hosting provider over a large hosting provider like Godaddy. One, you have a clear company
Why – in a world of website builder tools would someone possibly hire a professional web designer to do a website for them? Short
Hiring a web designer can be a tough decision for any business to make. It can be even more of a challenge working with
702 Pros was created in 2015 and registered as a business in Las Vegas, NV in early 2016.
Our web design services include service business web design, e-commerce web design, artist portfolio web design, photography portfolio web design, restaurant website design, entertainment

Meet Our Team

I’m Justin Young, the Founder and CEO of 702 Pros. Let’s build something amazing, challenge our minds with creative and insightful development.

Justin Young

Founder and CEO

Hi All! I oversee complete operations at 702 Pros. I’m passionate and dedicated to helping continue innovation and growth of local businesses.

Ashley Mathews

Chief Operations Officer

Kyla Estes

Client Relations

My name is Johann Olivares, I am a Web Developer for 702 Pros and I build and design awesome Web Applications with my web dev team and aim to get better each day. Sidenote – I am a huge Dragon Ball Fan.

Johann Olivares

Web Developer
Kyla Sloan | Kyla Estes | Client Management | Reception | Sales
Advertising with Us
Kyla SloanAdvertising Specialist
Our team has the digital and traditional marketing skills to get you in front of customers looking for your product or service.
Want to talk now? Give us a call at (702) 904-4262

Powered by OnSago

Add Your Business To the 702 Pros' Directory
Please add some general information about your business.
Want to talk now? Give us a call at (702) 904-4262

Powered by OnSago

702 Pros Landscape Logo Vector - with url and grow with digital catchphrase
2022 Sale

Get 20% off!

All Web Design Packages
Days
Hours
Minutes
Seconds
Want to talk now? Give us a call at (702) 904-4262

Powered by OnSago

Justin Young - Founder and CEO of 702 Pros | Web Design Las Vegas | Las Vegas Marketing Agency | best web design company in las vegas | Digital Marketing Agency | Web Design Agency | Top Web Design Agency
Schedule a Free Digital Strategy Call Our team is ready to grow your business!