How can PHP be used to set filtered pages to noindex for SEO purposes in a WordPress Woocommerce product catalog?
To set filtered pages to noindex for SEO purposes in a WordPress Woocommerce product catalog, you can use PHP to add a meta tag to the header of the filtered pages. This meta tag will instruct search engines not to index those pages, which can help prevent duplicate content issues and improve SEO.
function add_noindex_meta_tag() {
if (is_product_category() && isset($_GET['filter'])) {
echo '<meta name="robots" content="noindex">';
}
}
add_action('wp_head', 'add_noindex_meta_tag');
Keywords
Related Questions
- What are some common encoding issues that can arise when transferring data between Windows and Linux environments in PHP?
- How can PHP developers handle the case sensitivity of HTML attributes such as input types and names?
- What are some alternative approaches to monitoring file changes in a directory using PHP, without relying on the modification time of individual files?