Tag: WordPress

Show Only Category (Not Subcategory) Content

If you ever wanted to only show the content of the category you were on in the category view of WordPress (instead of the category you are on plus all of it’s subcategories – you can easily do so by adding the code below to the template that is used to show your category content

You would start your loop with this:

 

Put your title, content functions here

and where you normally see the call, put to close the additional (in_category) if statement.

This code gets the current category and then only displays categories that are in that category (not sub category)

WordPress Import/Export Option

Not too long ago whenever I had to move clients from one server to another, I would make a backup of the files and the database and then use SSH or FTP to move the files and then import the SQL file into MySQL. Over the past few months – I have switched to using the Import/Export option(Manage > Import/Export) to move simple sites. If you are moving your site to/from WordPress.com or from another server, take a look at the Import/Export option in WordPress to easily move all your data and attachments.

The Import/Export Process

You first need to log into your current WordPress installation and export your existing site data so you can import it on your new host. To do this, go to the WordPress Admin > Manage > Export. WordPress will create an XML file that you will then use to import. This is a really quick and easy way to move from one host to another if you are not comfortable with MySQL or phpMyAdmin (or any other database tool).

Import all your data (Import posts, comments, custom fields, pages, and categories from a WordPress export file) into your new WordPress installation. You can even import all your attachments which makes this even easier to migrate from one host to another.

You will also need to move your plugins, theme files, and any other files you might have – but this is a really easy way for most to move their data from one site to another – and it works great!

WordPress Update: 2.5.1

WordPress 2.5.1 has officially been released. The new version includes over 70 bug fixes, performance enhancements, and an important security fix. For more information on WordPress version 2.5.1, read the official WordPress version 2.5.1 documentation.
Download the latest versions of WordPress: 2.5.1

New Condition Tag: is_front_page() (WordPress 2.5)

Great news for WordPress theme developers. WordPress 2.5 now offers a new conditional tag: is_front_page(). We have long lived with other options (is_page(‘home’)) or other logic like that, but the is_front_page() simplifies defining the “home page” in our templates. Thanks guys!

WordPress 2.5 Beta 1 Initial Opinions

I took some time today to download the latest version of WordPress (2.5 beta 1) and decided this would be a perfect opportunity to switch to using subversion to manage my WordPress updates. Now that I am all switched over – updates will be much easier to manage.

My initial thoughts and opinions on WordPress 2.5:

  • The upgrade was painless – 5 minutes.
  • All my plugins worked except for my “Secure Admin” plugin – but that was out of date.
  • My theme works fine – after I made some adjustments to some of my AJAX features that relied on an outdated version of Prototype.
  • The new admin interface is well laid out for the most part. I am still not sure I am sold on the really light colors, but I will give it some time to grow on me.
  • The admin interface is cleaner – it no longer shows artifacts like post and category ID which only a few of us use. (If you want to see the post ID or cat ID, just hover over the edit link next to these items and you can see it in the URL – thanks Demitrious)
  • The post interface is much elongated due to the options that were once available in the right hand column (categories, password protect post, etc) are now below the post box instead of next to it. This is going to take some time to get used to.
  • Overall – this is a big release and I look forward to working with the changes and enhancements.

SDAC Recommends: WP Plugin: WP Super Cache

There is a new (relatively) caching plugin in town for WordPress called WP Super Cache and after using it now for a few version, I have to say I would recommend this over the old standard WP-Cache plugin. The plugin is easy to install, easy to configure, and will produce a noticeable load time decrease for your WordPress sites. There are also options to set if you want to “digg-proof” your site, use compression, or “lock down” your site during an expected traffic spike.

WordPress Logic: If Is Logged In

There are several tidbits of code that I have collected over the past few years that make it easier and easier to turn a simple WordPress installation into a very functional content management system (CMS). There are many times when it would be nice to show logged in members certain bits of information (certain categories, posts, or just a simple “Welcome back!”) and of course there is a simple way of doing this:

<?php if ( is_user_logged_in() ) echo 'Welcome back!';?>

That bit of code will allow you to do something like this which will allow you to show the logged in user’s preferred user name (selected in the User preferences), and then a list of member only pages (private page parent is page ID 20 – I am showing all sub pages of the members-only pages marked as private). If the user is not logged in, they will get a Welcome visitor! greeting :

<?php
if ( is_user_logged_in() ) :
  global $current_user;
  get_currentuserinfo();
?>	
  <p>Welcome back <?php echo esc_html( $current_user->display_name );?></p>
  <p>Here is a list of private pages only viewable by Members:</p>
  <ul>
  <?php wp_list_pages('post_status=publish,private&child_of=20');?>		
  </ul>
<?php else : ?>
  <p>Welcome, visitor!</p>
<?php endif;?>

You can make it as simple as a change in greeting for members and non-members, or put in specific logic like I did with showing the pages. The potential is limitless.

Updating From WordPress 2.2 to 2.3

I have been using WordPress for almost 4 years and have collected a number of database tables, plugin specific directories, and miscellaneous junk along the way on a number of my sites. I wanted to take some time and really do some spring cleaning. After a few hours – I was very pleased with the results and I wanted to share what worked for me.

Here are the steps I recommend to really clean out a WordPress installation:

  1. Make a backup of everything. You never know what you are going to get into – and a backup is very important incase things go bad.
  2. Make a test installation. I always use a test server when I know I am going to make several changes. This way, jappler.com was not down while I was testing and cleaning up. With your backup files, import your database on the test server, and grab the latest version of WordPress (hopefully using subversion)
  3. Remove old or unused plugin database tables. I then went into the WordPress database and removed (dropped) any tables that were created by any of my old or unused plugins that were still hanging around.
  4. Weed out old, unused plugins. I went through my plugins and deleted any old or unused plugins. I had a few “I should really use this” plugins that were never used – and to tidy up – I deleted them before uploading them to the test server environment. Make sure to also remove any files/folders that old plugins might have used in the root folder and or wp-content.
  5. Move your theme over. Upload the theme file over to the test server.
  6. Move your uploads over/miscellaneous files. Upload the uploads folder (wp-content) so you will have all your old uploads.
  7. Update WordPress. Run through the upgrade process (/wp-admin/upgrade.php).
  8. Debug your plugins. Log in, create a test post to make sure you can write to the database without any errors. I ran into a few problems with this, so I deactivated my plugins and activated them one by one. I found I had a few plugins that were not compatible with WordPress 2.3, but there were updates available, so I updated my plugins and moved on.
  9. Import Tags (if you have them). I used Ultimate Tag Warrior and WordPress has an import option for that (Manage > Import) for that.
  10. Display your WordPress tags in your WordPress theme. Now that tagging is available within WordPress without any plugins, you can easily display tags by using: You can also use a tag cloud (see Codex documentation)
  11. Make another backup. I always make another backup of my sites when I am happy with the end result – just incase something happened – I would not lose all my hard work.
  12. Enjoy your updated installation. Hey – you did it! A clean, lean, updated web site. Nice work. Now go and enjoy it!