Blog

Read our latest blog posts, learn something new, find answers, and stay up to date.

Conditionally Show Only On Home Page (Front Page)

There a are two functions that are used quite a bit to conditionally show content on the very front page (home page or page 1 of your blog). First – we had the function is_home(), but in WordPress version 2.5 – a new function was introduced: is_front_page().

You might think both would conditionally only display content on the home page (front page, page 1 of your blog) – but you actually need to use the following code to accomplish showing something ONLY on the front page of your paged blog:


<p>Show this text only on the home page</p>

So – if you want to easily show something on what I would consider the front page – use the code above to successfully achieve that. (This is particularly helpful if you have ads that run speficically on the home page and others that are ROS (run of site).

Further reading:

Get Top Parent Category (WordPress)

There are many times when you need to show or get the top most (root) parent category in WordPress – regardless of how many subcategories you might be deep. I have used this logic for page navigation (highlight the top parent tab) – as well as within some custom loops/sidebar code.

They way to do this:

// get parent category slug
$parentCatList = get_category_parents($cat,false,',');
$parentCatListArray = split(",",$parentCatList);
$topParentName = $parentCatListArray[0];
$sdacReplace = array(" " => "-", "(" => "", ")" => "");
$topParent = strtolower(strtr($topParentName,$sdacReplace));	

To test this you can simply put it in your header and echo out $topParent and you will see the “slug” of the category.
If you want to see the category name and not necessarily the slug – you can simply echo $topParentName.

WordPress 2.7 is Released

WordPress 2.7 has officially been released. The update contains a number of new features and functions but most notably – the admin has been redesigned and made very customizable. For more information on WordPress version 2.7, read the official WordPress version 2.7 documentation which also contains a video that covers the new features/interface.

Download the latest versions of WordPress: WordPress 2.7

Locked Out of vBulletin?

Recently I ran into an issue where I could not log into vBulletin (after changing the forum URL from (example.com/forums/ to forums.example.com). Lesson learned – you need to clear the cookie path in the admin before changing over to the new URL.

If it is too late though, you can download a file called “tools.php” that is in the do_not_upload file of the standard vBulletin folder. Upload that to the admincp folder along with the “install” folder and then go to your forum’s URL /admincp/tools.php. You will be prompted for your customer ID, and then you can reset your cookie settings.

Once you are done, make sure to delete the file and install folder. Login should once again work!

WordPress 2.6.5 is Released

WordPress 2.6.5 has officially been released (version 2.6.4 was skipped). The update contains a critical security fix (XSS exploit) as well as a few bug fixes. For more information on WordPress version 2.6.5, read the official WordPress version 2.6.5 documentation.
Download the latest versions of WordPress: WordPress 2.6.5

WordPress 2.7 Admin Notes

I decided to update a few of my sites to the latest WordPress 2.7 beta so I could see all the new changes. This post will cover some of the changes/details that are beyond the new look and feel of the WordPress Admin. WordPress 2.7 is scheduled to be released in the next few days. I will write more posts on WordPress 2.7 and the more technical changes in the next few days-weeks.

The Customizable Screen Options

There is now a handy tab “Screen Options” at the top of the admin window (right under Turbo/Logout) that allows you to customize each screen very easily.
Here is an example of how you can easily customize the Dashboard screen:

Screen Options - Dashboard

If you click on the “Screen Options” tab on the post page, you will get completely different options:

Screen Options - Post

This is very handy if you want to trim down the admin area or just remove items you do not use.

Media

WordPress users are adding more media to their posts/pages than ever before.

Media
I always felt that WordPress handled Media a little clunky and hard to explain to people that were not tech savy (what do you mean media is post specific…what if I want to use it in multiple posts…) – and I am happy to see the addition of the “Media” menu item so you can add media outside of a post. This will make adding media much easier for WordPress users who were often confused about the media management.

(You could edit media previously outside of a post (Media Library) but having a “Media” menu item is a great addition.

Appearance Menu

Where to put “Themes”, “Widgets” and “Editor” was always a big mystery.

Appearance
No title quite fit for all of them (Design menu in WordPress < 2.7). I think the folks responsible for this latest update finally got it right this time (with the help of some community feedback). Now users will have a better chance at finding widgets and themes with a more logical title for the grouping.

(Notice how the icon next to the menu title (Appearance) has a color hover state – another nice touch.

Time/Date Stamp

Overall – I think the 2.7 update really makes an impact for users that are not as comfortable with technical settings as us developers.

Time/Date Setting
This nice touch really shows how WordPress is great for non-technical people while not dumbing down the interface so much (they still leave an option in place for anyone comfortable with PHP to format the time and date as they please).

While options like this may seem small and something you can overlook – I know my clients will appreciate them.

Word Count

There are a number of really nice touches to WordPress 2.7 and I am happy to see this be one of them. A number of my clients are very word count conscious and this will make them all very happy.

Word Count

Show One WordPress Post

There is a great function you might be aware of that allows you to get one WordPress post and display it anywhere you would like (header, sidebar, home page, etc).

To show only one post, use the function get_post.

Example:

post_title;
$sdac_content = $show_post_id-&gt;post_content;
?&gt;
<h2></h2>
 

The code above will show the title and content of the post with the post ID of 10. If you are not sure what your post ID is, go to the manage screen in the WP-Admin, and hover over the post title. In your browser status bar, you will see the URL – and the post ID is the number at the end of the URL.

Remove Initial Flicker With Smooth Gallery

I recently created a site (in beta testing now) with Smooth Gallery and the client loved it.

The Problem:
The only issue was that upon the initial page load – all items in the gallery would flicker for a second or two while the first image loaded – causing this to not look professional at all.

The Solution:

  1. HTML: I took the example code:
    <div>
    
      <div class="imageElement" id="element">
          <h3>Item 1 Title</h3>
          <p>Item 1 Description</p>
          <a href="#" title="open image" class="open"></a>
          <img src="images/brugges2006/1.jpg" class="full" />
          <img src="images/brugges2006/1-mini.jpg" class="thumbnail" />
       </div>
     
     </div>
    

    I then added an ID to each div (id=”element1″) so that each div had a class of “imageElement” and a unique ID (element1, element2, etc).

  2. CSS: Now that I had IDs to style, I added the following to my style sheet:
    #element2 {display: none;}
    

By adding the 2 bits of code mentioned below, I was able to initially hide the content in the second div so that only the content in the first div appeared on page load. Once the script started running, it then changed the display from none to block automatically. Problem solved.