Design, Programming

Add Disqus comments to WordPress and edit CSS

For those of you who have struggled using the Disqus WP Plugin, this guide is for you. I tried using the plugin, but no matter which stylesheets I edited, I couldn't edit the Disqus CSS since the stylesheets are located within an iframe tag. Anyways here's what I did to fix that annoying box/margin error.

Using this guide, I added this JavaScript code to the end of my functions.php file.

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>';
}

Next, I replaced comments_template(); in my single.php and page.php files with this code:

//comments_template();
echo '<div class="disqus-div">';
disqus_embed('YY');
echo '</div>';

Replace YY with your Disqus short name (typically http://shortname.disqus.com). Finally, I added this CSS to my custom.css file. Replace XX with the margins of your liking.

.disqus-div {
  margin-top: XXpx;
  margin-right: XXpx;
  margin-left: XXpx;
}

You can also add any other CSS you want to this class. Cheers, hope this helps someone.

Standard
Design, Programming

Switched from Rails to WordPress for CMS

I was screwing around with the Refinery gem for the first half of today, and I kept wondering why everything seemed so outdated -- why the hell is it so ugly??  The last blogging gem available for Rails, Mephisto, was updated 4 years ago...  Needless to say, I didn't want to craft my own content management system or use any of the gem alternatives for my blog application.

So here I am, and I must say WordPress is light years ahead of its competition (I'm looking at you Joomla).  I love the ability to quick install plugins and customize all of the content of the fly.  The flexibility of this CMS reminds me a bit of Drupal, but much more intuitive.  Moreover, I've finally found a use for the GoDaddy Linux server that I regretfully paid for a year's worth of hosting, but more on that later.

The only gripe I have against WordPress -- and it's not even the company's fault -- is how many people have used the default themes!!  Just browsing the first few pages of themes, I realize that multitudes of websites haven't even touched the CSS.  Rather, they apply the default theme and hope that no one else uses the same theme...

For now, I'm going to see how enjoyable this WordPress system can be. Stay tuned for design updates!!

Standard