Web Analytics

Yoast SEO Tweaks: Titles, Breadcrumbs, and More

by Jason Unger, Founder

Photo by Mike Kenneally via Unsplash

Search engine optimization.

You know that it’s more than just getting links to your site, or stuffing keywords in hope that you’ll be found at the top of search results.

So, what is SEO?

It’s accessibility. It’s responsive design. It’s usability. It’s security. It’s minimalist code. It’s great content. Most of all, it’s being of use to your audience.

SEO is everything.

Every website that we build includes SEO fundamentals, and the WordPress plugin that we use and recommend to manage your site’s SEO is Yoast SEO.

There are plenty of tutorials for properly setting up and optimizing your Yoast SEO plugin; here, we share 3 tweaks we often use when building out our user-friendly, optimized websites.

Each code snippet goes in your theme’s functions.php file.

Breadcrumbs with Additional Context

Yoast includes a great, built-in function for Breadcrumbs – the navigation links that show you where you are in the overall site hierarchy. Breadcrumbs have long been known to be beneficial with few (if any) downsides.

The Yoast plugin can automatically generate your breadcrumbs, using your parent-child page or post-category relationships to display to the user where they “are” in the context of your site.

Sometimes, however, that automated hierarchy isn’t exactly how you want it displayed. Maybe you have a custom post type that should be treated as children of a static page, or maybe you want to treat one category of posts differently than all of the other categories.

The filter wpseo_breadcrumb_links allows you to rewrite the breadcrumbs, and insert your own custom links and text into the hierarchy. Here’s an example of adding a “Photos & Videos” page to the breadcrumb hierarchy directly above a custom post type called Gallery.

add_filter( 'wpseo_breadcrumb_links', 'dgtlnk_breadcrumbs' );

function dgtlnk_breadcrumbs( $links ) {
    global $post;
    if ( is_singular( 'gallery') ) {
        $breadcrumb[] = array(
            'url' => home_url() . '/photos-videos/',
            'text' => 'Photos & Videos',
        );

        array_splice( $links, 1, -2, $breadcrumb );
    }    
    return $links;
}

Use any conditional logic you’d like here to target specific posts or pages. The only downside of this is that you’re hard-coding in links and titles into your function.php file, which is usually not recommended.

Custom Page Titles

Sometimes there are situations where you need to overwrite a page title, and it can’t be done in WordPress. It isn’t especially common, but when you’re using third-party plugins that have their own title formats, it can be incredibly useful.

One such situation is with The Events Calendar, a popular plugin we often recommend when a website needs a full-featured calendar. They use their own page title format for the calendar pages, and because there’s not an “editable” page in WordPress, you can’t actually change the title.

Thankfully, Yoast SEO has a filter called wpseo_title that allows us to overwrite the title with whatever we want. Here’s an example of overwriting the page title of the “month” view in The Events Calendar.

add_filter( 'wpseo_title', 'filter_events_title_month' );

function filter_events_title_month( $title ) {
  if ( tribe_is_month() ) {
    $title = 'Events Calendar';
  }
  return $title;
}

To use it with a different page on your site, change the conditional to target your specific page, and make sure to return the $title.

Editor Box Placement

The final snippet of code is a function that we use on every WordPress website we build because it makes the editing experience easier to manage.

Normally, the Yoast editor box sits directly beneath the main content area when editing a page or post. But if you use custom fields – like we do with Advanced Custom Fields and its Flexible Layouts – the Yoast box can sometimes sit right in the middle of the page.

It’s an awkward place to be, since your writing process should focus on the content first, and then adding your meta title, meta description and Open Graph information last.

Thankfully, there’s a one-line function that forces the Yoast box to the bottom of the editor page, where it sits until you’re ready for it.

add_filter( 'wpseo_metabox_prio', function() { return 'low';});

There’s a reason why the Yoast SEO plugin is incredibly popular; it does the job well, and it’s extensible when you’re looking to make tweaks.

Have WordPress or SEO questions? Send us a note and we’ll get back to you with answers.

Avatar photo
About Jason Unger

Jason Unger is the Founder of Digital Ink. He built his first website on Geocities, and hasn't looked back since. Digital Ink tells stories for forward-thinking businesses, mission-driven organizations, and marketing and technology agencies in need of a creative and digital partner.

Other Stories You May Like

What’s your story?

Let’s share it with the world.

Let’s Do This

Close Window
All the Cool Kids are Doing it

Sign Up for the Digital Ink Newsletter

All the cool kids are doing it.