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/

Top comments (0)