Created
January 14, 2025 22:46
-
-
Save andrii-marushchak/8b57fd72bf1ea1e357f6a14276419579 to your computer and use it in GitHub Desktop.
disable indexation of pages of 'pt-br' language with WPML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$all_pages = array(); | |
/* change language (ensure WPML is properly set up) */ | |
do_action( 'wpml_switch_language', 'pt-br' ); | |
/* building query */ | |
$posts = new WP_Query( array( | |
'orderby' => 'title', // Corrected from 'sort_column' | |
'order' => 'ASC', // Corrected from 'sort_order' | |
'post_type' => 'page', | |
'posts_per_page' => - 1, | |
'post_status' => 'publish', | |
) ); | |
$posts = $posts->posts; | |
foreach ( (array) $posts as $post ) { | |
update_post_meta( $post->ID, '_yoast_wpseo_meta-robots-noindex', '1' ); | |
update_post_meta( $post->ID, '_yoast_wpseo_robots', 'noindex,follow' ); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment