0
0
Wordpressframework~30 mins

SEO plugins (Yoast, RankMath) in Wordpress - Mini Project: Build & Apply

Choose your learning style9 modes available
Basic SEO Setup with Yoast Plugin in WordPress
📖 Scenario: You are building a WordPress theme for a local bakery. You want to programmatically configure Yoast SEO defaults and add custom meta tags so that every page has proper SEO titles and descriptions without manual editing in the admin UI.
🎯 Goal: Use WordPress hooks and Yoast SEO filters to programmatically set default SEO titles, meta descriptions, and Open Graph metadata for your theme.
📋 What You'll Learn
Filter the Yoast SEO title for the front page
Filter the Yoast meta description for the front page
Add Open Graph meta tags using Yoast's wpseo_opengraph filter
Register a custom SEO settings page in the admin dashboard
💡 Why This Matters
🌍 Real World
Theme developers programmatically configure SEO defaults so clients get good SEO out of the box without manual Yoast configuration on every page.
💼 Career
WordPress developers need to know Yoast's filter hooks to build themes that ship with proper SEO defaults and integrate cleanly with the plugin ecosystem.
Progress0 / 4 steps
1
Filter the front page SEO title
Create a function called bakery_seo_title that takes $title as a parameter. If is_front_page() returns true, return 'Best Bakery in Town | Fresh Bread Daily'. Otherwise return the original $title. Hook it to the 'wpseo_title' filter using add_filter.
Wordpress
Need a hint?

Use is_front_page() to check if it's the homepage, and add_filter('wpseo_title', ...) to hook into Yoast's title output.

2
Filter the front page meta description
Create a function called bakery_seo_metadesc that takes $description as a parameter. If is_front_page() returns true, return 'Visit our bakery for fresh bread, cakes, and pastries made daily with love.'. Otherwise return the original description. Hook it to 'wpseo_metadesc'.
Wordpress
Need a hint?

Follow the same pattern as the title filter but use 'wpseo_metadesc' as the filter name.

3
Add Open Graph image for social sharing
Create a function called bakery_og_image that takes $image as a parameter. If is_front_page() returns true, return get_template_directory_uri() . '/images/bakery-og.jpg'. Otherwise return the original image. Hook it to 'wpseo_opengraph_image'.
Wordpress
Need a hint?

Use get_template_directory_uri() to build the path to your theme's image folder.

4
Add SEO defaults for custom post types
Create a function called bakery_cpt_seo_title that takes $title as a parameter. If is_singular('product') returns true, get the post title with get_the_title() and return it formatted as $post_title . ' | Bakery Menu'. Otherwise return the original title. Hook it to 'wpseo_title' with priority 20 so it runs after the front page filter.
Wordpress
Need a hint?

Use is_singular('product') to target your custom post type and get_the_title() to get the current post's title.