Skip to content

Excluding Category Terms or Tags #40

@leanca10

Description

@leanca10

Add the ability to exclude categories.
I'm currently adding a Yoast SEO category indexing check, but you can add it separately, for example, like how you can currently exclude post types.

/src/Output/ContentRenderer.php

use WPSEO_Taxonomy_Meta;

private function format_taxonomy_terms(string $taxonomy, int $post_id): array {
    $terms = get_the_terms($post_id, $taxonomy);
    if (!$terms || is_wp_error($terms)) {
        return [];
    }

    $lines = [];
    foreach ($terms as $term) {

    // Retrieve Yoast's explicit 'index' setting for this specific term
    $index_setting = WPSEO_Taxonomy_Meta::get_term_meta($term->term_id, $taxonomy, 'noindex');

    if ( $index_setting != 'noindex' ) {
        $lines[] = '  - name: "' . $this->escape_yaml($term->name) . '"';
        $lines[] = '    url: "' . $this->get_term_markdown_url($term) . '"';
    }


    }

    return $lines;
}

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions