-
Hi dear support ;
I am trying to apply all RankMath settings of a CTP term to a special archive page (where I modified the main query with with pre_get_posts based on the url structure).
I have succeed to apply the title and desciption like this :
/* With Rankmath SEO : change SEO Title */ function inject_seo_title($title) { if( ! is_admin() && is_archive() && get_product_type_from_url() != null ) { $title = RankMath\Post::get_meta( 'title', get_seo_content_id() ); } return $title; } add_filter( 'rank_math/frontend/title', 'inject_seo_title'); /* With Rankmath : Change SEO Description */ function inject_seo_description( $description ){ global $post; if( ! is_admin() && is_archive() && get_product_type_from_url() != null ) { $description = RankMath\Post::get_meta( 'description', get_seo_content_id() ); } return $description; } add_filter( 'rank_math/frontend/description', 'inject_seo_description');
But I cannot succeed to change the thumbnails.
For now I have this for the Facebook one :/* With Rankmath : Change SEO Thumbnail */ function inject_seo_thumbnail( $attachment_url ){ if( ! is_admin() && is_archive() && get_product_type_from_url() != null ) { $attachment_url = "https://mysite.com/wp-content/uploads/2020/05/default-thumbnail.png"; // a simple example } return $attachment_url; } add_filter( "rank_math/opengraph/facebook/image", 'inject_seo_thumbnail');
What am I doing wrong ?
Is there a better way to transfer all RankMath data of a post to another with filters ?Thank you 🙏
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The ticket ‘Apply RankMath Data of a post to another with filters’ is closed to new replies.