wp post meta update
You can use url_to_postid to convert a URL to its post id in the wp shell, or by creating a wp command.
for url in $(cat /tmp/urls-to-noindex); do
id=$(wp url2id $url)
if [ "$id" == "0" ]; then
echo $url - no post found
else
wp post meta update $id _yoast_wpseo_meta-robots-noindex 1
fi;
done
Create scaffolding for a command with wp scaffold plugin.
command.php snippet:
$url2post_command = function($args) {
if (count($args) == 0) {
WP_CLI::fail("no url");
return;
}
$post_id = url_to_postid($args[0]);
echo "$post_id\n";
};
WP_CLI::add_command( 'url2post', $url2post_command );
*BONUS* how to get post publish date:
wp post get
(or post_modified)