Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Coppa WPB
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Come disabilitare Disqus sui tipi di post personalizzati in WordPress

Nota editoriale: guadagniamo una commissione dai link dei partner su WPBeginner. Le commissioni non influenzano le opinioni o le valutazioni dei nostri redattori. Per saperne di più su Processo editoriale.

È necessario disabilitare i commenti Disqus sui tipi di post personalizzati in WordPress?

A volte i commenti possono scomparire dai tipi di post personalizzati dopo il passaggio a Disqus. Questo accade quando i commenti non vengono migrati correttamente, ma fortunatamente esiste una soluzione semplice e veloce.

In questo articolo vi mostreremo come disabilitare il sistema di commenti Disqus sui tipi di post personalizzati in WordPress.

How to Disable Disqus on Custom Post Types in WordPress

Perché ci siamo allontanati da Disqus

In passato abbiamo sperimentato l’uso del sistema di commenti Disqus su WPBeginner. Tuttavia, siamo tornati rapidamente ai commenti predefiniti di WordPress.

I motivi che ci hanno spinto ad abbandonare Disqus sono diversi, ma all’inizio abbiamo notato che alcuni commenti non comparivano sui nostri tipi di post personalizzati dopo il passaggio a Disqus.

Se si utilizza ancora Disqus per gestire e moderare i commenti in WordPress, una soluzione è importare manualmente i commenti. Tuttavia, questa operazione può richiedere molto tempo e fatica, soprattutto se i vostri post personalizzati hanno molti commenti.

Fortunatamente, esiste una soluzione più rapida per gli utenti di Disqus. Con questa premessa, vediamo come disattivare Disqus per i tipi di post personalizzati in modo semplice e veloce.

Disabilitare Disqus sui tipi di post personalizzati in WordPress

Prima di iniziare, è necessario assicurarsi di aver abilitato la sincronizzazione tra Disqus e il proprio sito web WordPress.

Nel menu di sinistra, selezionare Disqus e poi fare clic sulla scheda “Sincronizzazione”. È possibile fare clic su “Abilita la sincronizzazione automatica”, se non è già attiva.

Make Sure You Have Enabled Syncing Between Disqus and WordPress

Nota: a questo punto, potrebbe essere visualizzato il seguente errore: “Per abilitare questa funzione è necessario che siano configurati un Site Shortname, una API Secret Key e un API Access Token”. Se ciò accade, vi mostreremo come risolvere l’errore alla fine del post.

Successivamente, è necessario aggiungere del codice al proprio blog WordPress.

Spesso i tutorial vi chiederanno di modificare direttamente i file functions.php del vostro tema, ma non vi consigliamo questo approccio, perché un piccolo errore potrebbe causare una serie di errori comuni di WordPress o addirittura rompere completamente il vostro sito.

Detto questo, consigliamo di utilizzare il plugin gratuito WPCode. È il modo più semplice e sicuro per aggiungere codice personalizzato in WordPress.

Dopo l’attivazione, visitare la pagina Code Snippets “ + Add Snippet nella dashboard di WordPress.

How to disable Disqus for custom post types using code

Qui vengono mostrati tutti i diversi snippet già pronti che è possibile aggiungere al proprio sito. Questi includono snippet che consentono di disabilitare i blocchi di widget in WordPress e di rimuovere il numero di versione di WordPress.

Per aggiungere il proprio snippet, passare il mouse su “Aggiungi il tuo codice personalizzato” e fare clic su “Usa snippet”.

Disabling Disqus using WPCode

In questa schermata, digitare un titolo per lo snippet di codice personalizzato. Può essere qualsiasi cosa che aiuti a identificare lo snippet PHP.

Quindi, aprire il menu a tendina “Tipo di codice” e selezionare “Snippet PHP”.

How to add a PHP snippet to WordPress

A questo punto, è sufficiente incollare il seguente frammento di codice nell’editor:

function filter_dsq_can_load( $script_name ) {
if ( is_singular( 'custom_post_type_name' ) ) {
if ( 'count' === $script_name ) {
return false;
} elseif  ( 'embed' === $script_name ) {
return false;
} else {
return true;
}
}
}
add_filter( 'dsq_can_load', 'filter_dsq_can_load' );

Questo codice crea un filtro che controlla uno specifico tipo di post personalizzato e poi disabilita il modello di commento Disqus.

Per questo motivo, assicurarsi di sostituire custom_post_type_name con il nome del tipo di post personalizzato in cui si desidera disabilitare Disqus.

Sotto il riquadro del codice, vengono visualizzate le opzioni di inserimento. Se non è già selezionata, fate clic sul metodo “Inserisci automaticamente”, in modo che lo snippet venga inserito ed eseguito automaticamente in tutto il vostro blog WordPress.

Quindi, aprire il menu a tendina “Posizione” e fare clic su “Esegui ovunque”.

Running the Disqus code across your website

Quindi, scorrere fino alla parte superiore dello schermo e fare clic sulla levetta “Inattivo” in modo che diventi “Attivo”.

Infine, fare clic su “Salva” per rendere attivo lo snippet Disqus.

How to publish the Disqus code snippet

Risoluzione dei problemi: È necessario disporre di un nome breve del sito, una chiave segreta API e un token di accesso API

Quando si tenta di attivare la sincronizzazione automatica di Disqus, è possibile che venga visualizzato un errore: “Per abilitare questa funzione è necessario avere un nome breve del sito, una chiave segreta API e un token di accesso API configurati”.

A Disqus error message

In questo caso, è necessario creare un’applicazione Disqus collegandosi al sito web di Disqus. Se non l’avete ancora fatto, potete creare un account gratuito utilizzando il vostro indirizzo e-mail o accedere con un altro account, come quello di Facebook o Twitter.

A questo punto, cliccate sul link “Registrazione di una domanda”.

Registering a Disqus app

In questa schermata è possibile digitare alcune informazioni sulla propria applicazione, come il nome, l’organizzazione e il sito web in cui si intende utilizzare Disqus.

Una volta soddisfatti delle informazioni inserite, basta cliccare su “Registra la mia domanda”.

How to register a Disqus application

A questo punto, scorrete fino alla sezione “Accesso predefinito”.

Ora è possibile scegliere “Leggere, scrivere e gestire i forum” dal menu a discesa.

Changing the authentication status of a Disqus app

Quindi, scorrere fino alla parte inferiore della schermata e fare clic su “Salva modifiche”.

A questo punto è possibile fare clic sulla scheda “Dettagli”.

The Disqus API settings

Successivamente, scorrere fino alla sezione “Impostazioni OAuth”.

Qui si trovano la chiave API, il segreto API e il token di accesso. È necessario aggiungere queste informazioni alle impostazioni del plugin Disqus.

API settings, on the Disqus website

Nella dashboard di WordPress, selezionate Disqus dal menu di sinistra.

Quindi, fare clic sulla scheda “Configurazione del sito”.

The Disqus site configuration tab

In questa schermata, è necessario selezionare il link “Fare clic per apportare modifiche”.

Ora è possibile aggiungere la chiave API, il segreto API e il token di accesso nei diversi campi. È necessario aggiungere anche il nome breve del sito, se non è già stato fatto.

Updating the Disqus plugin settings

A questo punto, fare clic sul pulsante “Salva”.

Ora, se si seleziona la scheda “Sincronizzazione”, si dovrebbe vedere un nuovo pulsante “Attiva sincronizzazione automatica” invece di un errore.

Enabling the auto sync feature in Disqus

Speriamo che questo tutorial vi abbia aiutato a capire come disabilitare Disqus sui tipi di post personalizzati in WordPress. Potreste anche voler imparare come aumentare il traffico del vostro blog e vedere le nostre scelte degli esperti per i migliori plugin di social media per WordPress.

Se questo articolo vi è piaciuto, iscrivetevi al nostro canale YouTube per le esercitazioni video su WordPress. Potete trovarci anche su Twitter e Facebook.

Divulgazione: I nostri contenuti sono sostenuti dai lettori. Ciò significa che se cliccate su alcuni dei nostri link, potremmo guadagnare una commissione. Vedi come WPBeginner è finanziato , perché è importante e come puoi sostenerci. Ecco il nostro processo editoriale .

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Il kit di strumenti WordPress definitivo

Ottenete l'accesso gratuito al nostro kit di strumenti - una raccolta di prodotti e risorse relative a WordPress che ogni professionista dovrebbe avere!

Reader Interactions

14 commentiLascia una risposta

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Ludy Amano says

    The new Disqus Plugin (2018) requires some changes on this code to work properly:

    function filter_dsq_can_load( $script_name ) {
    // $script_name is either ‘count’ or ‘embed’.
    if ( ‘count’ === $script_name ) {
    return false;
    }

    return true;
    }
    add_filter( ‘dsq_can_load’, ‘filter_dsq_can_load’ );

  3. Hemang Rindani says

    WordPress is a great enterprise web content management service that allows a company to control website(s) effortlessly. With unlimited built-in tools and their flexibility & scalability, a developer can design website for any business requirements. It is advisable to keep the site interesting where adding a comment box will play a crucial role. Disqus is one of the easiest ways to add comment box on any page however sometimes it is essential to disable it on a few sections where you don’t require reader’s inputs. The method described in article is spot-on as I readily implemented it. Thanks for sharing.
    I feel Jetpack is a good alternative. It allows your readers to connect to your website and leave a comment in multiple ways. It uses default WordPress comment option, can connect to WordPress.com or allows users to login through Facebook, G+ and twitter. There are many other features that make Jetpack a great tool.

  4. Raunak Hajela says

    You showed us how to disable disqus in custom post type but what about enable? I recently added disqus on my interview custom post type but it’s not working. Why? I created two custom post types i.e Interviews and Blog. It is working in blog post type but not in interviews post type. Tell me how should I fix it.

    This is my code of both custom post types. I am using genesis template here –

    //* Register Interviews Post Type (Changes by NSS)
    add_action( ‘init’, ‘create_interview_post_type’ );

    function create_interview_post_type() {

    $labels = array(
    ‘name’ => __( ‘Interviews’ ),
    ‘singular_name’ => __( ‘Interviews’ ),
    ‘all_items’ => __(‘All Interviews’),
    ‘add_new’ => _x(‘Add new’, ‘Interviews’),
    ‘add_new_item’ => __(‘Add new’),
    ‘edit_item’ => __(‘Edit Interview’),
    ‘new_item’ => __(‘New Interview’),
    ‘view_item’ => __(‘View Interview’),
    ‘search_items’ => __(‘Search in Interviews’),
    ‘not_found’ => __(‘No Interviews found’),
    ‘not_found_in_trash’ => __(‘No Interviews found in trash’),
    ‘parent_item_colon’ => ”
    );

    $args = array(
    ‘labels’ => $labels,
    ‘public’ => true,
    ‘has_archive’ => true,
    ‘rewrite’ => array(‘slug’ => ‘interviews’),
    ‘taxonomies’ => array( ‘category’, ‘post_tag’ ),
    ‘supports’ => array( ‘title’, ‘editor’, ‘author’, ‘thumbnail’ , ‘custom-fields’, ‘excerpt’, ‘comments’)
    );

    register_post_type( ‘interview’, $args);
    }

    //* Register Blog Post Type (Changes by NSS)
    add_action( ‘init’, ‘create_nssblog_post_type’ );

    function create_nssblog_post_type() {

    $labels = array(
    ‘name’ => __( ‘Blog’ ),
    ‘singular_name’ => __( ‘Blog’ ),
    ‘all_items’ => __(‘All Posts’),
    ‘add_new’ => _x(‘Add new’, ‘Blog’),
    ‘add_new_item’ => __(‘Add new’),
    ‘edit_item’ => __(‘Edit Post’),
    ‘new_item’ => __(‘New Post’),
    ‘view_item’ => __(‘View Post’),
    ‘search_items’ => __(‘Search in Posts’),
    ‘not_found’ => __(‘No Posts found’),
    ‘not_found_in_trash’ => __(‘No Posts found in trash’),
    ‘parent_item_colon’ => ”
    );

    $args = array(
    ‘labels’ => $labels,
    ‘public’ => true,
    ‘has_archive’ => true,
    ‘rewrite’ => array(‘slug’ => ‘blog’),
    ‘taxonomies’ => array( ‘category’, ‘post_tag’ ),
    ‘supports’ => array( ‘title’, ‘editor’, ‘author’, ‘thumbnail’ , ‘custom-fields’, ‘excerpt’, ‘comments’ )
    );

    register_post_type( ‘nssblog’, $args);
    }

  5. Wakil Nikzad says

    Thank you for this great post.
    We’ve installed and configured Disqus plugin in our website. everything is almost great with it, except default commenting option. I wonder if there is any option for choosing Guest Commenting as default.
    However there are a lots of people who have Disqus account, but it differs in different societies/countries. For example: in Afghanistan most of the internet users don’t know about Disqus.

    • Travis Pflanz says

      You don’t need a Disqus account to comment on the Disqus system. You have to option to use Facebook, Twitter, Google+, Name/Email or Guest.

      I’m always logged in, so I had to logout to make sure this is the case.

      Logout and take a look.

  6. danh says

    I see what you are doing and like it. I think I’m having a load order problem. If I doctor the disqus plugin code to not add filter when my custom post type is being used, it addresses my problem:

    if ( ‘custom_post_type_name’ != get_post_type() ){
    add_filter(‘comments_template’, ‘dsq_comments_template’);
    }

    If I try your suggestion of removing the filter if it has been added, then it doesn’t work for me. I presume that functions.php is being executed before disqus.php, so there is no filter to remove at the time the removal is executed. I still haven’t worked out a fix.

Lascia una risposta

Grazie per aver scelto di lasciare un commento. Tenga presente che tutti i commenti sono moderati in base alle nostre politica dei commenti e il suo indirizzo e-mail NON sarà pubblicato. Si prega di NON utilizzare parole chiave nel campo del nome. Avremo una conversazione personale e significativa.