category og:type change

#849257
  • Resolved sandeep maheshwari
    Rank Math free

    This is my category page. I want to use ‘og:type” content=”website” instead of ‘og:type” content=”article”. Is there any code???

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    We apologize for the issue you are facing with changing the og:type for your category page. You can achieve this by using a filter in your theme’s functions.php file. Here’s how you can set the og:type to website for your category pages:

    add_filter('rank_math/opengraph/type', function ($type) {
        if (is_category()) {
            $type = 'website';
        }
        return $type;
    });

    This code checks if the current page is a category page and changes the og:type to website.

    Thank you for raising this concern! If you have any further questions or need assistance, feel free to reply to this ticket, and a human agent from the Rank Math Support team will assist you further.

    Sources:
    How to Make Your Theme Rank Math Compatible » Rank Math

    Hello,

    Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.

    You can use the following filter on your website to change the og:type of your website:

    add_filter( "rank_math/opengraph/facebook/og_type", function( $content ) {
    	$content = 'website';
    	return $content;
    });
    

    In case, you only want to change this for your categories, please apply the following filter:

    add_filter( "rank_math/opengraph/facebook/og_type", function( $content ) {
    	if(is_category()){ 
                $content = 'website'; //change here
            }
    	return $content;
    });
    

    Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps and please don’t hesitate to let us know if you have any other questions.
     
    Thank you.

    and Tags

    Hello,

    You can use the following filter to change the og_type tag for both categories and tag pages:

    add_filter( "rank_math/opengraph/facebook/og_type", function( $content ) {
    	if(is_category() || is_tag()){ 
                $content = 'website'; //change here
            }
    	return $content;
    });

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)

The ticket ‘category og:type change’ is closed to new replies.