jorgewp10
Forum Replies Created
-
Forum: Plugins
In reply to: [Contextual Related Posts] Exclude noindex pages from internal linkingThe first code works!
Thank you very much!
Forum: Plugins
In reply to: [Contextual Related Posts] Exclude noindex pages from internal linkingNo, it does not work 😅
Forum: Plugins
In reply to: [Contextual Related Posts] Exclude noindex pages from internal linkingIt almost works!
If I put that code with “noindex”, without the double-quotes:
add_action( 'pre_get_posts', function( \WP_Query $query ) { if( ! is_admin() && $query->get( 'crp_query' ) ) { $meta_query = [ 'relation' => 'OR', [ 'key' => 'rank_math_robots', 'value' => 'noindex', 'compare' => 'LIKE', ], [ 'key' => 'rank_math_robots', 'value' => '', 'compare' => 'NOT EXISTS', ] ]; $query->set( 'meta_query', $meta_query ); } return $query; });Only posts with noindex appear.
But, if I put “index”, it does nothing.
Thank you very much
Forum: Plugins
In reply to: [Contextual Related Posts] Exclude noindex pages from internal linkingHello Ajay,
I have tried to insert all possible values in the “value” field and it does not work.
Does the code goes in the functions.php, doesn’t it?
Forum: Plugins
In reply to: [Contextual Related Posts] Exclude noindex pages from internal linkingHello Ajay,
I received a reply from RankMath:
“Rank Math uses these values in the database for the index/noindex (wp_postmeta table):
meta_key: rank_math_robots meta_value: a:1:{i:0;s:5:"index";} or a:1:{i:0;s:5:"noindex";}So I guess if I use the following code in the functions.php, it should works:
<?php add_action( 'pre_get_posts', function( \WP_Query $query ) { if( ! is_admin() && $query->get( 'crp_query' ) ) { $meta_query = [ 'relation' => 'OR', [ 'key' => 'rank_math_robots', 'value' => '1', 'compare' => '!=', ], [ 'key' => 'rank_math_robots', 'value' => '', 'compare' => 'NOT EXISTS', ] ]; $query->set( 'meta_query', $meta_query ); } return $query; });Am I right?
Thank you very much
Forum: Plugins
In reply to: [Contextual Related Posts] Exclude noindex pages from internal linkingYes, I have opened a support ticket to RankMath. As soon as I get a reply I will let you know
Thank you very much for your help
Forum: Plugins
In reply to: [Contextual Related Posts] Exclude noindex pages from internal linkingThank you very much for you reply
I have been researching and RankMath works with filters. For example, to set noindex for product filters, it uses:
add_filter( 'rank_math/frontend/robots', function( $robots ) { if (is_paged() || is_product_category() || isset($_GET['filters'])) { $robots['index'] = 'noindex'; return $robots; } return $robots; });How could I adapt it?
Thank you very much for your support!
Forum: Plugins
In reply to: [Contextual Related Posts] Exclude noindex pages from internal linkingHello Ajay,
I use Rankmath to set the noindex
Thanks