Wow. Here’s some great WordPress mod info…

I do a lot of WordPress design, and although I appear pretty good at it from looking at my custom sites, I’m actually more of a hack than anything.  I’m a master tinkerer.  It’s nothing for me to just start changing things and see if they work, and eventually they do.

But not one thing.

When you get into some more advanced designs, you may want to show only posts from a certain category on a page or even have posts from multiple categories in several containers on your page.   The problem is that this has always screwed up my post navigation.  As soon as I bring out the query_posts to select my category, I can no longer move from one post to the next.  I know that a lot of people must have this same problem.

Today, however, I just happened to type the magic word combination into Google and found the place in WordPress Support that has the solution.

The key is this.

You replace the beginning of the loop, which normally looks like this:

<?php if (have_posts()) : ?>
<?php query_posts(“category_name=somecat”); ?>
<?php while (have_posts()) : the_post(); ?>

With this:

<?php if (have_posts()) : ?>
<?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; query_posts(“category_name=somecat&paged=$paged”); ?>
<?php while (have_posts()) : the_post(); ?>

And suddenly it works like a charm.

The support thread where I got the information is here:

And when I’m finished with the current site I’m using it on, I’ll do a link so you can see a working example.

All I can say is, “What a relief!”

That’s one of the many great things about WordPress.  Any problem that you have, someone has already had it before,and someone else has figured it out.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s