Roughly four months ago I talked a bit about how to set up your blog so only the admin can see an edit button on blog posts. For whatever reason, I’ve always set this up on each of my websites and really get a lot of use out of it. Much along those same lines, Michael of WPCandy has written a post explaining how to display content so only the admin can view it. This goes well beyond the edit button and allows you to setup just about anything to display for the admin.

In hist post, Michael provides some code that looks at the user id to determine if the user has admin privileges and then displays whatever you tell it to for that user. Here is the code:

<?php global $user_ID; if( $user_ID ) : ?>
<?php if( current_user_can('level_10') ) : ?>
<a href=”http://yourdomainurl.com/stats/“>Stats</a>
<?php else : ?>

<?php endif; ?>
<?php endif; ?>

If you run a multi-author blog and would like to make this stuff available to editors, authors, contributors, and more, you can easily adjust the user level to determine who sees your display.

Great find Michael!

Digg This! | Stumble it! | Add to Del.icio.us | | Print This! |

Most WordPress themes, by default, come with Recent Posts displayed automatically. Depending on the type of blog you run, it is possible that you would prefer to display Recent Posts per category. If this is the case, here is what you need to do to only display recent posts for specific categories.

First, you’ll want to find your Recent Posts code, which is usually found in the sidebar. It will look something like this:

<h2>Recent Posts</h2>
<ul>
<?php get_archives('postbypost', 10); ?>
</ul>

As always, make sure you have a backup of the file in question before making any changes. You’ll then want to replace the above code with the following code:

<ul>
<?php $recent = new WP_Query("cat=1&showposts=10"); while($recent->have_posts()) : $recent->the_post();?>
<li><a href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); ?>
</a></li>
<?php endwhile; ?>
</ul>

Where is says cat=1, you’ll want to insert the number assigned to the category that you want to display the posts from. You can find this from your Manage -> Categories page. You can also adjust the number of posts to be displayed where it says showposts=10.

This could be useful to someone who wants to display the most recent few posts from a few different categories in their sidebar.

[via ReadyWPThemes]

Digg This! | Stumble it! | Add to Del.icio.us | | Print This! |

While browsing my feeds, I noticed an interesting post over at JohnCow explaining how to make money online with missing pages. The author noticed that a lot of traffic was ending up on his error page (almost 26,000 people to be exact) and felt that there had to be a better way to use this page so there wasn’t so much wasted traffic.

In the authors example, the idea is to redirect all traffic that hits his 404 page to his “make money” page, which contains affiliate links and other ways to get paid. While this example probably wouldn’t apply to most of us, I do think that it might be a good idea to redirect these bloggers to a more important page on your blog, such as your homepage.

In order to do so, you simply need to do a quick edit to your 404.php page (which most themes should have). Before attempting, make sure you have a backup copy of your 404.php page in case something goes wrong. You’ll want to add this code to the top of your 404.php page:

<?php
header ('Location: http://yourhomepageurl/’ );
?>

You’ll of course want to manually enter your homepage URL. If you have a favorite post you’d like to promote, you could instead add the URL to that post.

If you’d prefer not to redirect your 404 page, you can always customize it to help the potential reader to find what they were looking for.

Digg This! | Stumble it! | Add to Del.icio.us | | Print This! |

We all know that duplicate content can be a problem. People copy your work, re-post it on their website, then you both are penalized for duplicate content! Unfortunately, there isn’t much that can be done about that, but did you know that often blogs have duplicate content within their own blog? The biggest culprit for duplicate internal content is your archives page, which is usually used for categories and monthly archives. Unless you only display partial posts in your archives, you’ll want to make sure Google doesn’t index it. If you aren’t handy with Robots.txt, you can instead use this code to easily tell Google not to index your archive.php page.

<?php if(is_archive()){ ?><meta name="robots" content="noindex"><?php } ?>

You’ll want to grab that code and paste it anywhere in the header of your theme above the closing of the head tag. That way, Google will not index these, and search engines won’t refer traffic to your archive pages instead of your single post pages.

Digg This! | Stumble it! | Add to Del.icio.us | | Print This! |

Back in early November I wrote about a great WordPress help sheet released by WPCandy that primarily focused on a bunch of PHP snippets for WordPress developers. You can download the PDF and have quick and easy access to these code snippets when you need it.

Today I noticed that Michael has followed this up with yet another great free PDF designed to be a more advanced WordPress help sheet. This one is similar to the WordPress code compilation that I created awhile ago, but his help sheet covers a few more advanced code snippets while still mixing in a lot of basic code that theme developers might use.

If you spend any amount of time working with WordPress themes, I recommend you click over and grab a copy of this PDF so that you have it when you need it!

Digg This! | Stumble it! | Add to Del.icio.us | | Print This! |

I had a reader request for some help with their blogroll recently. The WordPress blogroll has gone through many changes over the past year, and a lot of the WordPress themes authors out there didn’t update their themes with the new code used to call the blogroll.

The old code still works, but it doesn’t let you take advantage of the new blogroll capabilities.  If you have set up your blogroll with different categories, but noticed that all of them display under a single category, it is probably because your blog’s theme is still using the original code that didn’t allow for much configuration. You’ll probably find something like this:

<?php get_links()' ?>

or

<?php get_links_list()' ?>

If you want a more configurable code, you will want to use something like the following:

<?php wp_list_bookmarks('categorize=1&before=<li>&title_before=<h2>&title_after=</h2>&category_before=</n>&category_before=</n>&after=</li>&orderby=url'); ?>

This code will display your blogroll, but will let you have separate lists for your different blogroll categories. I’ve customized it to display the category title as a Header 2 and use bullet points to display the content, but you can do a variety of things. For more customization options, you’ll want to check out the WordPress List Bookmarks page and adjust the code as needed.

Digg This! | Stumble it! | Add to Del.icio.us | | Print This! |