Jul 15, 2012

Disqus WordPress plugin without

Filled under: ,

Disqus WordPress plugin without

Disqus is an advanced system of comments, with many advantages over the native WordPress comments, as published from social profiles, community integration, monitoring and moderation of comments and more integrated desktop.

In addition to WordPress, there is a plugin so the installation process is really easy, just create account disqus.com and follow the wizard after installing the plugin.

Now if you are someone who likes to have controlled and WordPress plugins install the minimum possible , you can replace the system of comments by Disqus WordPress plugin without .

It only requires a few steps, a bit of code:

0. Create an account on Disqus

First of all you must be logged in disqus.com and then add the site (or sites) that are going to use Disqus as a commenting system. Write the short name ( shortname ), then we will use the end of this guide.

1. Create the function to Disqus

Open your plugin functions, or the file functions.php in your current theme and add the following code:


//FunciĆ³n Disqus sin plugin
function disqus_embed($disqus_shortname) {
    global $post;
    wp_enqueue_script('disqus_embed','http://'.$disqus_shortname.'.disqus.com/embed.js');
    echo '<div id="disqus_thread"></div>
    <script type="text/javascript">
        var disqus_shortname = "'.$disqus_shortname.'";
        var disqus_title = "'.$post->post_title.'";
        var disqus_url = "'.get_permalink($post->ID).'";
        var disqus_identifier = "'.$disqus_shortname.'-'.$post->ID.'";
    </script>';
}


Let's take a look at the code:


  1. Load the JS: I know we can not do anything if we do not charge JS
  2. Put the "div" to load the comments. We echo <div id = "disqus_thread"> </ div> because the divisor Disqus need this ID to load the comments.
  3. Configuration variables Disqus JS: We have to set these variables to recognize Disqus page. Actually no need to define the variables disqus_title and disqus_url because Disqus can obtain the URL and tag "title" in the URL of the page, but if someone visits your site with an address containing, for example " ...? utm_source feedburner = "the URL will be different from the original and could cause problems, or simply not load the Disqus commenting system.


And a little more, save changes and go to the next - and final - step.

2. Insert the function in your theme

Once you create the function you only need to locate the call to the template comments in your theme files single.php and page.php , usually as follows:

<?php comments_template( '', true ); ?>

... And replaced by the following code:

<?php disqus_embed('myblog'); ?>

As you can imagine, you have to replace " myblog "for the short name with which you have named your site to register it in Disqus.com step before you can use the system just prepare these 2 codes, and I've signed up at first, do not forget.

6 comments:

  1. Thank you for your usefull information.I like this kind of post which tell us much wonderfull massage.

    ReplyDelete
  2. I discovered your blog site on google and check a few of your early posts. Continue to keep up the very good operate.

    ReplyDelete
  3. Consequently, in that case discover a corporation that provides remarkable and amazing web design as well as development service making use of the most recent resources and technological know-how.

    ReplyDelete
  4. Good post will have to try Disque on our own site for our blog page.

    ReplyDelete
  5. Very nice tutorial I just did that and it’s very helpful. The DISQUS commenting system is one amazing tool you would like to try out. The flexibility you get while designing your comment area is simply mind-blowing. You can place your comments above or below your posts, sort comments by age, host of other features that may come in handy.

    ReplyDelete