e-mail: MP@MikePayne.co
phone: +1 (801) 949-7137
twitter: @the_mikepayne

Getting Facebook Comment Count Within WordPress

I’ve been working with the Facebook Comment integration into WordPress lately. Mostly because it can help cut down on spam, but also because of the grammer checker and social media benefit. I couldn’t really find a good solution online for pulling the number of comments on any given post, so here is what I ended up with. I included this in my functions.php file, and just put this: <?php get_fb_comment_count(); ?> in my single.php file where I want the comment number to be displayed.

function get_fb_comment_count() {
     global $post;
     $url = get_permalink($post->ID);
     $filecontent = file_get_contents('https://graph.facebook.com/?ids=' . $url);
     $json = json_decode($filecontent);
     $count = $json->$url->comments;
     if ($count == 0 || !isset($count)) {
          $count = 'No Comments';
     } elseif ( $count == 1 ) {
          $count = '1 Comment';
     } else {
          $count .= ' Comments';
     }
     echo $count;
}

HTAccess block linking to your images

through the power of .htaccess we can prevent anyone from linking to images on your site. If someone tries to post an image from your site in their blog, you can redirect it to a new image of your choosing.

Read more

Don’t Track Analytics for Admin

web-analytics-and-statistics

I often run into situations where I am editing a site, or checking my pages, but do not want to count the time i spend on my own site to count towards my Analytics Tracking.

Read more

WordPress Plugin Development For Beginners

plugins

The power of WordPress is its ability to be customized and expand the core functionality using plugins. Plugins utilize PHP as well as the default functions, hooks, filters, and actions that are shipped with WordPress. We’ll cover the basics of writing our own WordPress plugins from scratch.

Read more

Shortcode to Hide Content from Users that Aren’t Logged In

block-content

A common issue many beginner WordPress users run into is blocking certain content from users that aren’t registered or logged in. Here is a short, simple solution in the form of a shortcode.

Read more
Copyright ©MMXI Mike Payne