Query block - how to get query id on paged pages to add custom meta tags
Description Pagination in the query block adds the query variable "query-queryid-page" (e.g. /?query-ef108cb9-page=2) to display the result on the page. In terms of SEO, sometimes we need to add the "noindex" meta tag to the paginated pages. Is it possible to get the randomly generated query block IDs to use in custom_query_var ... or do you have a plan for creating filters?
@madanpraba currently we don't have a way of adding the noindex. But I'm keeping this as feature for the next release. Thanks
This is something we should look at as soon as 1.8.0.
A "dirty" solution would be to do something along the lines of this:
add_action( 'wp_head', function() {
$params = $_GET;
foreach ( (array) $_GET as $key => $value ) {
$query_param = preg_match( '/query-(\w+)-page/', $key, $matches );
if ( ! empty( $matches ) ) {
if ( isset( $_GET[ $matches[0] ] ) && $_GET[ $matches[0] ] > 1 ) {
echo '<meta name="robots" content="noindex" />';
}
}
}
}, 0 );
I'd prefer something more concrete, though.