I am setting up a custom WordPress site and I want to use my own SEO optimization. I am looking for a WordPress function to fill in for my meta tags so that I don't have to create a different header.php for each page.
I have implemented functions such as bloginfo();
and wp_site_icon();
, but when it comes to og:local, og:type, etc., are there functions to do this?
<!-- SEO Optimization -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="description" content="<?php bloginfo(' description' ); ?>" />
<meta property="og:image" content="<?php wp_site_icon(); ?>" />
<meta property="og:image:width" content="108" />
<meta property="og:image:height" content="108" />
<meta property="og:locale" content="en_US" />
<meta property="og:type" content="website" />
<meta property="og:title" content="FFHC Pain Management | Georgia Pain Management Doctors" />
<meta property="og:description" content="Our pain doctors are dedicated to providing the best holistic pain management techniques available." />
<meta property="og:site_name" content="Family First Healthcare Pain Managament" />
<link rel="canonical" href="https://firstpainmanagement.com/" />
I expect each function to return whichever page the user is on and the values that page contains, but currently, the output would only return what I hard code it to be.
I have found this nice cheat sheet (https://cdn.rawgit.com/hostinger/banners/b2416e91/tutorials/pdf/Wordpress-Cheat-Sheet-V-1.pdf), but I can't find a function that would work like wp_title()
. Is there something like perhaps wp_description()
? Does bloginfo('description')
work like that?
For og:type
you could create a PHP function that determines if it is a post, home page, archive, etc. and then set a variable that is returned. There is no built in function for it.
For og:locale
if this is specifically for one site, I would keep it hard coded since that tells the language that is being used by the site. If you have more than one language you could try doing something like this:
<meta property="og:locale" content="en_US" />
<meta property="og:locale:alternate" content="fr_FR" />
As a side note...
For the title, if you're looking to use the title of the site (not a specific post) then you could use bloginfo('name') . ' | ' . bloginfo('description')
. If you haven't already seen it, here are all of the parameters you can use for the bloginfo() function.