rank math seo og meta change

#110505
  • /**
    * Allows theme developers to change the OpenGraph type of the page.
    *
    * @param string $type The OpenGraph type string.
    */
    add_filter( ‘rank_math/opengraph/type’, function( $type ) {
    return $type;
    });

    How to use this code?

    How to change <meta property=”og:type” content=”article”>
    I want on all site <meta property=”og:type” content=”website”>
    and for blog articles only <meta property=”og:type” content=”article”>

    Now only home page <meta property=”og:type” content=”website”>
    and other <meta property=”og:type” content=”article”>
    Help please

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

    Thank you for getting in touch with us.

    You can try it as follows to change the meta for the pages:

    
    /**
     * Allows theme developers to change the OpenGraph type of the page.
     *
     * @param string $type The OpenGraph type string.
     */
    add_filter( 'rank_math/opengraph/type', function( $type ) {
     if(is_page()){
         return "Website";
     }
    	return $type;
    });
    

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

    Thanks
    I used this function.
    But I have one more problem.
    I create custom post type for FAQ with taxonomy ‘faq’
    and when I check this post type with is_page(‘faq’) or is_singular(‘faq’) in this function, meta <meta property=”og:type” content=”object”> don’t changed on content=”Website”
    All other pages changed all right with this function

    add_filter( 'rank_math/opengraph/type', function( $type ) {
     if(is_page()){
         return "Website";
     }
    	return $type;
    });

    Please help to change meta on custom post type

    Hello,

    If your custom post type name is actually FAQ, then you can check it using is_singular( 'FAQ' ) . If you wish to add the rule for the taxonomy too, you can use is_post_type_archive( 'FAQ' ).

    For reference, please use WordPress functions reference page: https://developer.wordpress.org/reference/functions/

    Hope this helps you.

    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 3 replies - 1 through 3 (of 3 total)

The ticket ‘rank math seo og meta change’ is closed to new replies.