It looks like nothing was found at this location. Maybe try one of the links below or a search?
/* ========================================================= * UNIFICAR TODAS AS TAGS EM post_tag (WP core) * - Mantém categories / photo categories intactas * - Photos passam a usar post_tag * - /photos-tag/slug/ (tax antiga) -> 301 -> /tag/slug/ * - Se termo existir só na tax antiga, cria/espelha em post_tag automaticamente * ========================================================= */ /** * Detecta a taxonomia "antiga" de tags de fotos (casos comuns). * (Tu disseste photo-tag, mas muitas instalações usam photo_tag.) */ function wpst_get_legacy_photo_tag_taxonomy() { $candidates = array( 'photo-tag', 'photo_tag', 'photos_tag', 'photos-tag' ); foreach ( $candidates as $tax ) { if ( taxonomy_exists( $tax ) ) { return $tax; } } return ''; } /** * 1) Garantir que post_tag (tags normais) também se aplica ao CPT photos. * Assim "todas as tags" passam a ser a mesma taxonomia: post_tag. */ add_action( 'init', function () { if ( post_type_exists( 'photos' ) ) { register_taxonomy_for_object_type( 'post_tag', 'photos' ); } }, 20 ); /** * Helper: garante que existe um termo em post_tag com o mesmo slug/nome. * Retorna o term_id do post_tag. */ function wpst_ensure_post_tag_from_legacy_term( $legacy_term ) { if ( ! $legacy_term || is_wp_error( $legacy_term ) ) return 0; $slug = $legacy_term->slug; $name = $legacy_term->name; $existing = get_term_by( 'slug', $slug, 'post_tag' ); if ( $existing && ! is_wp_error( $existing ) ) { return (int) $existing->term_id; } $created = wp_insert_term( $name, 'post_tag', array( 'slug' => $slug ) ); if ( is_wp_error( $created ) ) { // Se falhar por conflito de slug/nome, tenta obter novamente $existing = get_term_by( 'slug', $slug, 'post_tag' ); return ( $existing && ! is_wp_error( $existing ) ) ? (int) $existing->term_id : 0; } return isset($created['term_id']) ? (int) $created['term_id'] : 0; } /** * 2) Redirecionar /tag/slug/ quando não existe post_tag mas existe na tax antiga: * - cria a post_tag * - mantém o URL /tag/slug/ como canónico (não duplica SEO) */ add_action( 'template_redirect', function () { if ( is_admin() || ! is_tag() ) return; $slug = get_query_var( 'tag' ); if ( ! $slug ) return; // Se já existe em post_tag, está ok $t_post = get_term_by( 'slug', $slug, 'post_tag' ); if ( $t_post && ! is_wp_error( $t_post ) ) { return; } $legacy_tax = wpst_get_legacy_photo_tag_taxonomy(); if ( ! $legacy_tax ) return; // Se existe na tax antiga, cria em post_tag e recarrega a mesma URL $t_legacy = get_term_by( 'slug', $slug, $legacy_tax ); if ( $t_legacy && ! is_wp_error( $t_legacy ) ) { wpst_ensure_post_tag_from_legacy_term( $t_legacy ); // Recarrega /tag/slug/ (agora já existe post_tag) wp_redirect( home_url( '/tag/' . $slug . '/' ), 302 ); exit; } }, 0 ); /** * 3) Se alguém entra pelo arquivo da tax antiga (ex.: /photos-tag/slug/): * - garante termo em post_tag * - 301 para o canónico /tag/slug/ */ add_action( 'template_redirect', function () { $legacy_tax = wpst_get_legacy_photo_tag_taxonomy(); if ( ! $legacy_tax ) return; if ( is_admin() ) return; // Estamos no arquivo da tax antiga? if ( ! is_tax( $legacy_tax ) ) return; $term = get_queried_object(); if ( ! $term || empty($term->slug) ) return; // cria/espelha em post_tag wpst_ensure_post_tag_from_legacy_term( $term ); // mantém paginação se houver $paged = get_query_var('paged'); $url = home_url( '/tag/' . $term->slug . '/' ); if ( $paged && $paged > 1 ) { $url = home_url( '/tag/' . $term->slug . '/page/' . intval($paged) . '/' ); } wp_redirect( $url, 301 ); exit; }, 1 ); /** * 4) (Opcional mas recomendado) Quando o tema pede get_term_link() da tax antiga, * devolver /tag/slug/ para não gerar links duplicados. */ add_filter( 'term_link', function( $termlink, $term, $taxonomy ) { $legacy_tax = wpst_get_legacy_photo_tag_taxonomy(); if ( $legacy_tax && $taxonomy === $legacy_tax && is_object($term) && ! empty($term->slug) ) { return home_url( '/tag/' . $term->slug . '/' ); } return $termlink; }, 10, 3 );
It looks like nothing was found at this location. Maybe try one of the links below or a search?