Salta al contenuto
  • CATEGORIES
  • La Community Connect.gt
  • Presentati alla Community
  • News Ufficiali da Connect.gt
  • Internet News
  • A Scuola Di
  • Digital Marketing
  • Intelligenza Artificiale
  • SEO & GEO
  • Web Marketing e Content
  • Google Analytics e Web Analytics
  • Google Ads & Advertising
  • YouTube
  • TikTok, Instagram e altri Social
  • Google Adsense, Affiliazioni e Guadagno
  • E-Commerce
  • Coding e Sistemistica
  • Help Center: consigli per il tuo progetto
  • Hosting e Cloud
  • Coding
  • CMS & Piattaforme Self-Hosted
  • Annunci e Collaborazioni
  • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
  • Collaborazioni WEB e Lavoro: offro e cerco
  • Impresa, Fisco e Leggi
  • Consulenza Legale e Professioni Web
  • Consulenza Fiscale, Imprese, Startup e P.Iva
  • Gli Off Topic
  • PC, Smartphone e altri Hardware
  • Tutti i Software
  • GT Fetish Cafè
  • Discussioni
  • 0 Non letti 0
  • Recenti
  • Hashtag
  • Popolare
  • Utenti
  • Privacy
  • Termini e condizioni
  • © 2026 Search On Media Group S.r.l.
Collassa
Connect.gt
Il network Search On
Connect.gt WMF AI Festival Accademia Advanced SEO Tool AgentCy Social Media Strategies Search Tech
Registrati Accedi
Connect.gt
Stream Interest Categorie Hashtag
  1. La community italiana di SEO, marketing digitale e AI
  2. Categorie
  3. Coding e Sistemistica
  4. CMS & Piattaforme Self-Hosted
  5. Cme non fare comparire la categoria madre ma solo la sotto categoria

Cme non fare comparire la categoria madre ma solo la sotto categoria

Pianificato Fissato Bloccato Spostato CMS & Piattaforme Self-Hosted
4 Post 2 Autori 671 Visualizzazioni 1 Seguito
  • Da Vecchi a Nuovi
  • Da Nuovi a Vecchi
  • Più Voti
Rispondi
  • Risposta alla discussione
Effettua l'accesso per rispondere
Questa discussione è stata eliminata. Solo gli utenti con diritti di gestione possono vederla.
  • J
    J
    johnny.p
    scritto su ultima modifica di
    User 0
    #1
    Cme non fare comparire la categoria madre ma solo la sotto categoria

    Ciao a tutti, sto apportando delle modifiche alle categorie del mio sito ma in questo momento i permalink vengono così visualizzati nomedominio. it/ category/category+nome città/postname
    Vorrei invece fare comparire questa struttura nomedominio . com/category+nomecittà/postname. Category sta ad es. per "concerti" e "category+ nome città" sta ad es. per "concerti-roma")Mi è stato consigliato di usare il Seo by Yoast e selezionare nelle impostazioni il permalink il flag "rimuovi categoria", ma continua a non risolversi.
    Allo stesso tempo, però, vedo che nelle impostazioni del template i permalink sono impostati sulla "struttura personalizzata" con il seguente codice inserito a suo tempo prima di creare le sotto categorie: /%category%/%postname%/ . Ci può essere un conflitto che non fa eliminare la category madre?

    Sapete dirmi come fare?
    Grazie a tutti!
    Johnny

    1 Risposta Ultima Risposta
    Miglior risposta 0
    0
    • M
      M
      mcrapanzano
      scritto su ultima modifica di
      User 0
      #2

      Prova questa soluzione:

      // Remove category base
      add_filter('category_link', 'no_category_parents',1000,2);
      function no_category_parents($catlink, $category_id) {
      $category = &get_category( $category_id );
      if ( is_wp_error( $category ) )
      return $category;
      $category_nicename = $category->slug;

      $catlink = trailingslashit(get_option( 'home' )) . user_trailingslashit( $category_nicename, 'category' );
      return $catlink;
      

      }

      // Add our custom category rewrite rules
      add_filter('category_rewrite_rules', 'no_category_parents_rewrite_rules');
      function no_category_parents_rewrite_rules($category_rewrite) {
      //print_r($category_rewrite); // For Debugging

      $category_rewrite=array();
      $categories=get_categories(array('hide_empty'=>false));
      foreach($categories as $category) {
          $category_nicename = $category->slug;
          $category_rewrite['('.$category_nicename.')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?category_name=$matches[1]&feed=$matches[2]';
          $category_rewrite['('.$category_nicename.')/page/?([0-9]{1,})/?$'] = 'index.php?category_name=$matches[1]&paged=$matches[2]';
          $category_rewrite['('.$category_nicename.')/?$'] = 'index.php?category_name=$matches[1]';
      }
      // Redirect support from Old Category Base
      global $wp_rewrite;
      $old_base = $wp_rewrite->get_category_permastruct();
      $old_base = str_replace( '%category%', '(.+)', $old_base );
      $old_base = trim($old_base, '/');
      $category_rewrite[$old_base.'$'] = 'index.php?category_redirect=$matches[1]';
      
      
      //print_r($category_rewrite); // For Debugging
      return $category_rewrite;
      

      }

      // Add 'category_redirect' query variable
      add_filter('query_vars', 'no_category_parents_query_vars');
      function no_category_parents_query_vars($public_query_vars) {
      $public_query_vars[] = 'category_redirect';
      return $public_query_vars;
      }
      // Redirect if 'category_redirect' is set
      add_filter('request', 'no_category_parents_request');
      function no_category_parents_request($query_vars) {
      //print_r($query_vars); // For Debugging
      if(isset($query_vars['category_redirect'])) {
      $catlink = trailingslashit(get_option( 'home' )) . user_trailingslashit( $query_vars['category_redirect'], 'category' );
      status_header(301);
      header("Location: $catlink");
      exit();
      }
      return $query_vars;
      }

      1 Risposta Ultima Risposta
      Miglior risposta 0
      0
      • M
        M
        mcrapanzano
        scritto su ultima modifica di
        User 0
        #3

        Oppure il Plugin [h=2]Custom Permalinks[/h]

        1 Risposta Ultima Risposta
        Miglior risposta 0
        0
        • J
          J
          johnny.p
          scritto su ultima modifica di
          User 0
          #4

          Ciao mcrapanzano , grazie dell'info. Credo che mi orienterò sul plug in che mi sembra più semplice

          A presto!

          1 Risposta Ultima Risposta
          Miglior risposta 0
          0

          Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.

          Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.

          Con il tuo contributo, questo post potrebbe essere ancora migliore 💗

          Registrati Accedi
          Rispondi
          • Risposta alla discussione
          Effettua l'accesso per rispondere
          • Da Vecchi a Nuovi
          • Da Nuovi a Vecchi
          • Più Voti


          • Accedi

          • Non hai un account? Registrati

          • Accedi o registrati per effettuare la ricerca.
          • Primo post
            Ultimo post
          Home Accedi Registrati
          Menu
          • CATEGORIES
          • La Community Connect.gt
          • Presentati alla Community
          • News Ufficiali da Connect.gt
          • Internet News
          • A Scuola Di
          • Digital Marketing
          • Intelligenza Artificiale
          • SEO & GEO
          • Web Marketing e Content
          • Google Analytics e Web Analytics
          • Google Ads & Advertising
          • YouTube
          • TikTok, Instagram e altri Social
          • Google Adsense, Affiliazioni e Guadagno
          • E-Commerce
          • Coding e Sistemistica
          • Help Center: consigli per il tuo progetto
          • Hosting e Cloud
          • Coding
          • CMS & Piattaforme Self-Hosted
          • Annunci e Collaborazioni
          • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
          • Collaborazioni WEB e Lavoro: offro e cerco
          • Impresa, Fisco e Leggi
          • Consulenza Legale e Professioni Web
          • Consulenza Fiscale, Imprese, Startup e P.Iva
          • Gli Off Topic
          • PC, Smartphone e altri Hardware
          • Tutti i Software
          • GT Fetish Cafè
          • Discussioni
          • Non letti 0
          • Recenti
          • Hashtag
          • Popolare
          • Utenti
          • Privacy
          • Termini e condizioni
          • © 2026 Search On Media Group S.r.l.