DEV Community

David Loor
David Loor

Posted on • Originally published at davidloor.com on

How to change the meta title of the WooCommerce shop page using the Rank Math plugin

In a WooCommerce site that I am working on, I tried to update the meta title of the default shop page from the Rank Math configuration page and for some weird reason I was not able to accomplish it. So, at the end, I needed to use the following snippet to make it happen:

/**
 * Filter to change the meta title for the shop page.
 *
 * @param string $title
 */
add_filter( 'rank_math/frontend/title', function( $title ) {
    if ( is_shop() ) {
        return 'My nice meta title for the shop page';
    }
    return $title;
});

Enter fullscreen mode Exit fullscreen mode

If you are curious about what other hooks are available in the Rank Math plugin, you can check the following link: https://rankmath.com/kb/filters-hooks-api-developer/

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more