Other posts related to wordpress

Building a WordPress Blog People Want to ReadTonight I finished reading Scott McNulty’s book, Building a WordPress Blog People Want to Read.  It’s a good book for beginners wanting to learn how to use WordPress.  But I think the title is misleading, it doesn’t teach how to write blog content that people want to read.

Something new I learned while reading this book was about the admin functionality to convert categories to tags or tags to categories.  Simply go to your Dashboard, go to Tools > Import and select Categories and Tags Converter.  The URL for converting categories to tags is /wp-admin/admin.php?import=wp-cat2tag and for converting tags to categories is /wp-admin/admin.php?import=wp-cat2tag&step=3.

I also learned about Steve DeGraeve’s Favicon Generator which seems somewhat useful.

Share

WordPress Emoticons

 | July 28, 2009 3:00 AM

Building a WordPress Blog People Want to ReadI have been using emoticons for awhile in my posts but I did not about the breadth of them until I read about them in Scott McNulty’s book, Building a WordPress Blog People Want to Read.

Scott points to WordPress Codex’s helpful document, Using Smilies.  Now I know how to LOL. 😆

You can also replace the emoticons with your own set by replacing the files in wp-includes/images/smilies. You just have to use the same file names.

Share

If a post is protected and the user does not have permission to view the post then the User Permissions Plugin redirects the user to the index page of the website, i.e. “/”.

On my blog I had previously updated this plugin so that the user is redirect to the Protected Posts page.  I have since updated the plugin to redirect to the login page if the user does not have permission to view the post.  This is because on my blog if a user does not have permission it is most likely because she is not registered and/or not logged in.  Once the user logs in she will be redirected to the post she intended to view.

To figure out how to do this I followed several steps.

  1. Figure out what properties of the post were available to me.To do this I used the new Reflection API in PHP 5 to find this information.
    Reflection::export(new ReflectionObject($post))

    It turned out that there was a page describing all the post properties available in the API.

  2. Figure out how to get information about the blog itself.  Fortunately there is a simple get_bloginfo template tag.  I used this to get the URL of the blog.
  3. Figure out how to create the login URL and redirect to that URL.  I determined that though my URL permalink structure is site-url/year/month/day/post-name, e.g. http://www.kimplicity.com/fkim/blog/2009/06/12/sample-post/, that if I gave a URL of the structure site-url/post-name that it would properly redirect.  But then I determined that an even better solution would be to use the URL site-url?p=ID where ID is the post ID.

Here are the modifications I made.

*** user-permissions.php
***************
*** 98,104 ****
  {
    if (is_single () || is_page ()) {
      if (empty($id) || $id == $post->ID) {
!       $permissions->redirect ();
      }
    }
    else
--- 98,104 ----
  {
    if (is_single () || is_page ()) {
      if (empty($id) || $id == $post->ID) {
!       $permissions->redirect ($post->ID);
      }
    }
    else
*** permissions.php
***************
*** 155,163 ****
!       function redirect ()
  {
    if ($this->redirect_read > 0)
      wp_redirect (get_permalink ($this->redirect_read));
!   else
!     wp_redirect ('/fkim/blog/2009/05/28/protected-posts/');
    die ();
  }
}
--- 155,166 ----
!       function redirect ($postid)
  {
    if ($this->redirect_read > 0)
      wp_redirect (get_permalink ($this->redirect_read));
!   else {
!     $site_url = get_bloginfo('siteurl');
!     $login_url = $site_url . '/wp-login.php?redirect_to=' .
!                  $site_url . '/?p=' . $postid;
!     wp_redirect ($login_url);
!   }
    die ();
  }
}
Share

As mentioned previously, I installed the User Permissions Plugin (version 0.8.4) so that I could control who gets to read my more personal posts.  The plugin was working great until I realized that it was denying access to posts that it should not be.

First I had to figure out how to debug WordPress plugins.  I first tried the wp pear debug plugin but I could not figure out how to get it to output anything.  Later I realized it was making things worse because for some reason it cleared all the roles from the current user.  Then I found the WiPeD debug plugin which was simple to use.

After many hours of debugging I determined that the problem was an incompatibility between the User Permissions Plugin and the Yet Another Related Posts Plugin (YARPP).  The problem was that if a public post had at least one related post that was protected the User Permissions Plugin would redirect the user away from the public post.

The simple solution was to not redirect if the post that is protected is not the post being displayed.  The trick was finding the post ID but fortunately this article, Retrieve and Get WordPress Post ID Outside the Loop as PHP Variable, turned out to be immensely helpful.

It turns out there are three different ways to get the post ID.

  1. global $wp_query;
    $post_id = $wp_query->post->ID;
  2. global $post;
    $post_id = $post->ID;
  3. global $id;
    $post_id = $id;

Using this information I modified user.permissions.php in the User Permissions Plugin source and now this plugin works happily with YARPP.  Here are the modifications I made.  I sent these modifications to the plugin author, John Godley.

***************
*** 90,109 ****
  {
    if (!empty ($posts))
    {
!           global $current_user, $id;

!           foreach ($posts AS $idx => $post)
      {
        $permissions = Permissions::get ($post->ID);
        if ($permissions && $permissions->can_read ($current_user) == false)
        {
!               if (is_single () || is_page ()) {
!                 if (empty($id) || $id == $post->ID) {
!                   $permissions->redirect ();
!                 }
!               }
          else
!                 unset ($posts[$idx]);
        }
      }

--- 90,106 ----
  {
    if (!empty ($posts))
    {
!           global $current_user;

!           foreach ($posts AS $id => $post)
      {
        $permissions = Permissions::get ($post->ID);
        if ($permissions && $permissions->can_read ($current_user) == false)
        {
!               if (is_single () || is_page ())
!                 $permissions->redirect ();
          else
!                 unset ($posts[$id]);
        }
      }
Share

I noticed some blogs list at the end of the post other posts that are related to them.  They also list the most popular posts.

To do related posts I first tried the Yet Another Related Posts Plugin (YARPP).  However I got some strange results like my post Wild Goose Chase – Yawning Angels being related to the posts WaMu Free Checking and Poisonous Wild Mushrooms.  Also this plugin didn’t find any posts related to my Sort of Vegetarian post.

I next tried the WordPress Related Posts plugin but that did not work at all, I think it wasn’t updated for WordPress 2.7.1.  So I went back to YARPP and configured it to not show excerpts, not promote the plugin, and to use a lower match threshold of 4.25.

For popular posts I first tried the WordPress Popular Posts plugin but it reported no popular posts.

Next I tried the WordPress.com Popular Posts plugin which uses WordPress.com Stats.  Fortunately it works quite well even though I got a warning during installation that it had not been tested with WordPress 2.7.1.  The only configuration change I made was to list the number of views for each post.

I always wanted to be popular. 🙂

Update 06-07-2009: I just found out that YARPP does not play well with User Permissions.  If a post that is not protected has related posts that are protected then the User Permissions plugin redirects instead of allowing the user to see the unprotected post.

Share

By accident I discovered that you can schedule posts.  Here is what you do to schedule a post to be published in the future.

  1. Click on the Edit link next to "Publish immediately" inside the Publish box of the Edit Post screen.

    image

  2. Change the date to a future date when you want the post to be published.  Then click on the OK button.

    image

  3. After you clicked on the OK button in the previous step the Publish button changed to say Schedule.  Click on the Schedule button to schedule your post to be published in the future.

    image

This is how I scheduled all my Dominion posts.  I actually wrote all of them on June 1 but I scheduled only one to appear per day.  There are still four more posts. 🙂

Update 2009-08-19: To cancel a scheduled post you have to set the scheduled date to a date in the past.  Then the Schedule button should change back to the Publish button.  Press the Publish button and the post will be published with the date you just set.

Share

Blog Update Services

 | May 29, 2009 10:43 AM

blog ping services

When you install a WordPress blog on Dreamhost it automatically sets up the update service to notify people that you’ve updated your blog.

The default pinging service is http://rpc.pingomatic.com/
but this blog article suggests using these.

http://rpc.pingomatic.com
http://www.blogpeople.net/servlet/weblogUpdates
http://ping.myblog.jp
http://ping.bloggers.jp/rpc/
http://bblog.com/ping.php

And that’s what I did.  What do you use?

Share

Stickiness

 | 10:07 AM

In an attempt to help increase traffic and make my site “stickier” I added two plugins, Add to Any and Subscribe to Comments.

Share/Save/BookmarkThe first plugin adds this lovely button which allows the reader to share a post from my blog or save it to their blog or bookmarks.

The second plugin allows users who comment on one of my posts to be notified via email if there are new comments made on the same post by simply clicking on the checkbox like below.

I was considering a different plugin, Comment to Reply Notification, because users were complaing about the Subscribe to Comments plugin and recommended this plugin.  The Comment to Reply Notification is newer and is designed for WordPress 2.7, the latest version as of this writing.  However this plugin did not work for me and thankfully Subscribe to Comments is.

Share

This article, Google Analytics script, has a comment thread where people debate whether Google Analytics or WordPress.com Stats is better.  The consensus seems to be that you might as well use both and that though Google Analytics has more info it might be overkill.

WordPress.com Stats was easy enough to install and I could use the same WordPress.com API key for all my blogs.  The only issue was that to see the stats in my dashboard I had to enable third-party cookies in my browser (normally I don’t to keep out unwanted cookies).

Google Analytics took a little longer to set up but was still easy.  I had to create separate Google Analytics accounts for each of my blogs.  Google asked if I wanted to share my data and though I was suspicious I said yes because they said I would have access to other services if I did.  I then configured the plugin for each blog with the correct Analytics Account ID.  For this blog the footer does not call wp_footer(); for some reason so I placed the tracking script in the header.  For my professional blog I placed the tracking script in the footer since that is the default.

I have a feeling I am going to end up liking WordPress.com stats better because it is simpler and more tuned to the stats I want from a blog.  Below is a sample screenshot.

WordPress.com Stats screenshot

But I am glad I am also at the same time compiling stats on Google Analytics.

Share

Protected Posts

 | May 28, 2009 7:13 AM

You are most likely viewing this page because you tried to access a post that is protected.  To view that post you must be registered and logged in.  After doing this please try accessing the post again.

Restricted Content

Previously I was concerned about privacy, i.e. my blog posts showing up in unexpected places and being read by unintended guests.  I tried to address it by having everyone log in to view my blog but that proved to be a problem because RSS feeds no longer worked.  Recently I opened my blog to search engines and noticed a spike in traffic but I think that was mostly from Google.

I have searched for a solution for awhile and I finally found a good compromise, the User Permissions Plugin.  By using this plugin I can restrict certain posts to only be available to readers who are registered and logged in.  Also these restricted posts will not show up in RSS feeds.  I modified the plugin to redirect to this post instead of “/“.

The downside is that my regular readers will have to be logged in to read these restricted posts.

Regular readers please register if you have not already and always log in if you want to read all the posts, especially posts about my kids.

Share