About “opengraph/image_sizes”

#235553
  • Resolved
    Rank Math free

    Hello.
    Why doesn’t this code work in functions.php? https://snipboard.io/S6uP94.jpg

    add_filter( 'rank_math/opengraph/image_sizes', 'override_images');
    	 function override_images() {
    		if ( is_post_type('job_listing') ) {
    		 return 'thumbnail';
    	}
    }

    It is necessary to specify a special og:image size (thumbnail) for the custom post type (post_type=job_listing).

Viewing 1 replies (of 1 total)
  • Hello,

    Thanks for contacting us. Sorry for the delay and any inconvenience that might have been caused due to that.

    Can you please replace the code you are using with the filter given below:

    add_filter( 'rank_math/opengraph/image_sizes', function( $sizes ) {
            global $post;
            if (get_post_type($post->ID) == 'job_listing') {
                    return $sizes['thumbnail'];
            }
    	return $sizes;
    });

    This should work for you. Let us know if it doesn’t. We are here to assist.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this ticket.