Labor of Love

Posted in WordPress
0

This blog was supposed to be many things: design, code, and a bit of WordPress love. Recently, though, the content I wrote tend to gravitate to the latter; not that it’s something bad, I do love talking about WP. I just think that, hey, maybe it’d be a good idea to grow that interest into its own blog.

And so, WPLover is born.

Having a goal of providing “bite-sized WordPress news, and then some”, I hope I could grow that blog as well as this one. Managing multiple blogs is hard, so I cheated a bit by keeping in mind that WPLover will mostly contain snippet of news update instead of fully-blown article every time.

From now on, this blog will focus more on web design and code, so stay tuned for more articles on that area.

Oh, and thank you very much for reading. No, honestly.

WordPress 2.5 RC1 First Impression

Posted in WordPress
0

Delayed one week from the initial release date of March 10, 2008, WordPress 2.5 RC1 is finally out. Here are a few points worth mentioning from the announcement post:

For the past few months, we’ve been working with our friends at Happy Cog — Jeffrey Zeldman, Jason Santa Maria, and Liz Danzico — to redesign WordPress from the ground-up.

Yes, yes, yes. Music to my ears. Here’s my old post regarding Happy Cog’s involvement in redesigning WordPress’ backend.

You might also notice there are some new colors, the dashboard feels much fresher and lighter. If you’re jonesing for the old look under your user options you can now select the “classic” colors and get those old blues back. (It’s also pluggable so people can easily add or share their own color schemes.)

So, you can change the admin’s color schemes by creating plugins. Interesting. Here’s Ozh explaining how to do that in details. Now, I’m just itching to go to Colour Lovers and grab a few lovely schemes for this.

The software is basically done and stable, and could be released today

So, this is it. What I’m waiting the most from 2.5 is the redesigned admin, and if you’re like me, it’s probably quite safe to believe that the new design is there and ready to test. Now, let’s play!

Will Somebody Fix Codex’s Search Functionality?

Posted in WordPress
2

Don’t you think it’s kind of weird that searching for “the_category” on WordPress Codex results in quite a lot of page, but none of it shows Template Tags/the category, the correct page for it?

I mean, the search term is also used on the correct page’s URL, so what’s the big deal here? Note that searching it via Google shows the correct page as the first result.

I frequently had some problems searching for various other things too. I love Codex, but sadly I must say the search functionality could use some help. What do you guys think?

WordPress QuickTips: Getting a Post’s ID

Posted in WordPress
4

In a project I’m working on, I need to find the ID of a Post (a Page, actually, but the truth is that this works for both) so that the theme does not display the sidebar on this particular Post, but still showing for the rest.

At first I’m looking at the Template Tag the_ID(). Unfortunately, this function automatically prints out the Post’s ID instead of returning the ID when called. In other words, the following is not possible:

// Check whether the Post's ID is 5.
// This does not work.
if(the_ID()==5) do something...

…because the_ID() does not return 5. It turns out, the working method is by using $post->ID:

// Check whether the Post's ID is 5.
// This works.
if($post->ID == 5 ) do something...

Also, in my experience, the $post variable is still available after The Loop is done, very useful in my quest of displaying/hiding sidebar depending on the Post’s ID:

// This works.
<div id="content">

  // The Loop
  <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
       // ...the usual content displaying stuff...
    <?php endwhile; ?>
  <?php endif; ?>
</div>

<?php
  // Outside The Loop!
  if($post->ID != 21) get_sidebar(); ?>

I suppose this works well on template files that only display 1 content (e.g: single.php, page.php). Expect crazy things to happen when calling $post outside The Loop inside template files that actually loops more than once (index.php, category.php, etc).

Finding Query Count for a Certain Part in a WordPress Theme

Posted in WordPress
1

Michael Castilla’s post on modifying individual posts in the loop got me to test the query count between the double loop and single loop with counter method. This is my way to count that query count.

Say the Magic Word

This is how you would display the (current) query count in your theme:

<?php echo get_num_queries(); ?>

This piece of code is usually found inside footer.php, right at the very end of the code to display the total queries needed to display that single page. The secret is that you can place it just about anywhere inside your theme, and it will obediently display the total of query so far.

Also, you can have more than one of these in one go, so you could place one before and one after a certain part of a theme:

<?php echo get_num_queries(); ?>

The Loop here...

<?php echo get_num_queries(); ?>

…and you will have the query count before the loop and after it. Subtract the number and there you go, you have the total of queries invoked for The Loop.

Upgrading WordPress the “Sneaky” Way Part II: Finding Files Changed from Previous Version

Posted in WordPress
0

Back in December 2007 I wrote a post explaining a method to upgrade your WordPress install by simply overwriting the changed files instead of reuploading everything. Back then I was assuming that the “new version available” post will always tell you what files are changed so it’s easy for you to know what to upload.

However, today 2.3.3 is out and the announcement does not mention anything about changed files. Darn.

Trac Browsing to the Rescue

So, I decided to look around WordPress’s Trac. Now, I don’t know much about Trac, so I’ll let Wikipedia explain:

Trac is an open source, web-based project management and bug-tracking tool[…] (Source)

Okay. So, in essence, this is the place where you go to find the WordPress source code in various versions, with notes on modifications and whatnot, from the earliest to the most updated. So it’s the right place to go.

And the nice thing is that it allows you to compare the difference between versions. Exactly what we needed.

First, go to the tags directory of the source. There you can see a list of every WordPress version, from 1.5 to 2.3.3 and everything in between. Choose the most updated version. In our case, 2.3.3.

If you do it right, this page will be opened. At the bottom of the page there’s the View Changes… button. Exactly what we need. Click it.

You will see a form like below:

Finding changed files using Trac

Except that in your case the input field might still be empty. Well, punch in the numbers the way I did: in the From field it’s “tags/x.x.x“, x.x.x is for the previous version, while in the To field it’s “tags/y.y.y” for the current version. Click View Changes. You don’t have to worry about the numbers on the two Revision input boxes.

And now you’ll see the list of files changed from previous version:

WordPress Trac's list of changed files

Those are the one you should upload and upgrade. Refer to the old tutorial for more detailed steps.

Now, if you’d excuse me, I have some upgrading to do.

Prologue 140 Characters Limit Mod Update

Posted in WordPress
1

Prologue gets updated, and here’s the list of new features/fixes:

  • The front page now shows a stream of recent updates instead of one update per user
  • Pages now have their own template and look much better
  • Avatars are only shown once for sequential posts by the same author (front page and tag pages)
  • Post titles are no longer empty, they are generated based on the beginning of each post
  • Works out of the box for WordPress.org 2.3.2

And so, I have updated the Twitter-like 140 chars limit mod as well.

Download Prologue 140 Characters Limit Mod here.