Custom Post title og image default vs all posts og images

#55360
  • Resolved Steve White
    Rank Math free

    I’ve set an og image / thumbmail for a custom post type, but the global og setting takes priority and displays. Is there a way to prioritize the custom post type’s image in settings when using a custom post type?

    • This topic was modified 3 years, 10 months ago by Steve White.
    • This topic was modified 3 years, 10 months ago by Steve White.
Viewing 12 replies - 1 through 12 (of 12 total)
  • Alberto
    Rank Math business

    Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
    ​​​​​​​
    We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    HI there, I’m sorry, the notification of your response went to SPAM. I’ve included login access above as requested. Thank you.

    Alberto
    Rank Math business

    Hello,

    I can’t see any login details in the Sensitive Data section, could you check it?

    Looking forward to help you.

    It’s there. It’s a link to temporarily login without a password. You have access until 6/14. Please let me know if you have any trouble.

    Alberto
    Rank Math business

    Hello,

    I have added a screenshot in the Sensitive Data section showing you how I am not able to find any login data (nor URL) in the Sensitive Data section. Could you check it?

    Looking forward to help you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    Thank you for contacting Rank Math today.

    I have checked a nnumber of your published posts and the social image appearing is the one set on the page under Rank math social meta. You can use this tool: https://developers.facebook.com/tools/debug/ to test how your links social meta appear.
    Please let us know how this goes.

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hello,

    Thank you for the follow up.

    I have recorded a screencast testing the link you have provided. You can check and confirm the image set social share is shown in Facebook debugger. Please let us know what we are missing.

    Looking forward to helping you. Thank you.

    ​​​​​​

    That’s not the image for custom post type! They’re similar but the global og meta IS different than the og image for the custom post type.

    Please see here: https://www.loom.com/share/c92623b3fb9e4ab4921e4662f73ab69e

    And then see what happens in the debugger: https://www.loom.com/share/c2ee7c87b3c24b689885b36afd95527b. It shows the GLOBAL social share image instead of the custom post type image in the RankMath settings.

    Hello,

    Rank Math uses the image from Post Type tab on archive pages. For posts, the fallback image is used from the Global tab. You can change this by adding the following code in your theme’s functions.php file:

    
    add_filter( 'rank_math/opengraph/facebook/og_image', function( $img ) {
    	if ( ! is_singular() ) {
    		return $img;
    	}
    	$image = rank_math_fallback_image( 'facebook' );
    
    	return $image ? $image : $img;
    });
    
    add_filter( 'rank_math/opengraph/twitter/twitter_image', function( $img ) {
    	if ( ! is_singular() ) {
    		return $img;
    	}
    	$image = rank_math_fallback_image( 'twitter' );
    
    	return $image ? $image : $img;
    });
    
    function rank_math_fallback_image( $network ) {
    	global $post;
    	$image = get_post_meta( $post->ID, "rank_math_{$network}_image", true );
    	if ( ! $image && ! has_post_thumbnail() ) {
    		$image = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_facebook_image" );
    	}
    
    	return $image;
    }
    
    

    I wanted to add this code from Theme Editor but it looks like you have not give us the write access. Please add the code at the end of the functions.php file before closing PHP tag, that should fix the issue.

    Hope that helps. If there is anything else, please let us know.

    That’s working! Thank you.

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘Custom Post title og image default vs all posts og images’ is closed to new replies.