• Hi,

    for method cvcs_restrict_terms_by_meta_on_archive_callback I needed to make a change, because get_queried_object() wasn’t present anymore through the hook “pre_get_posts” when having the AAM plugin activated.

    function cvcs_restrict_terms_by_meta_on_archive_callback( $query ) {

    if ( ! $query->is_main_query() || is_admin() ) {
    return;
    }

    if ( $query->is_archive() ) {
    // Taxonomie und Term-Slug aus Query holen
    $taxonomy = $query->get( 'taxonomy' );
    $term_slug = $query->get( 'term' );

    // Nur wenn Taxonomie aktiviert ist
    $cvcs_selected_taxo = get_option( 'cvcs-taxonomy-enabled' );
    $selected_taxo = ! empty( $cvcs_selected_taxo ) ? $cvcs_selected_taxo : array();

    if ( ! empty( $taxonomy ) && in_array( $taxonomy, $selected_taxo, true ) && ! empty( $term_slug ) ) {
    // Term-Objekt holen
    $term = get_term_by( 'slug', $term_slug, $taxonomy );

    // Status aus Term-Meta prüfen
    $meta_key = 'cv_term_status_draft';
    $meta_value = '1';

    if ( $term && get_term_meta( $term->term_id, $meta_key, true ) === $meta_value ) {
    // Term aus der Query ausschließen
    $tax_query = $query->get( 'tax_query' );
    if ( ! is_array( $tax_query ) ) {
    $tax_query = array();
    }

    $tax_query[] = array(
    'taxonomy' => $taxonomy,
    'field' => 'slug',
    'terms' => $term_slug,
    'operator' => 'NOT IN',
    );

    $query->set( 'tax_query', $tax_query );
    }
    }
    }
    }

The topic ‘Problem with get_queried_object in method when activating AAM plugin’ is closed to new replies.