January 29th, 2007 - by ses5909

I haven’t upgraded any of my blogs to WordPress 2.1 yet as I don’t feel like fixing anything that might break when I do. Pure laziness I know. Last week though, a friend asked me for some help on a site he was developing for a client. He was using WordPress as a CMS for the entire site rather than just the blog. He created a new template for the home page and in the sidebar he wanted to show the snippets of the most recent posts. There are plugins for this but he wanted to avoid using them. I knew there was a function that would show a snippet of the post with a “Read More” link called the_excerpt. This function only works within the_loop which wouldn’t work in this case. So, I needed to actually write some code *gasp* and the query I used was:


$news=$wpdb->get_results("SELECT ID,post_title, SUBSTR(post_content, 1, 30) as post_content FROM wp_posts
WHERE post_status= 'publish' ORDER BY ID DESC LIMIT ".$how_many);

This didn’t work though. It got not only the posts but also the pages. I didn’t have access to his site directly so I tested this on my version of WordPress 2.0x. It worked fine. This is when I asked him what version he was using and he said 2.1. Which of course made sense because it was a new site, might as well use the latest and greatest, right?

So I tried to find out why it wasn’t working and what the changes were in 2.1 that affected pages but apparently my google search terms sucked and neither of us could find it. So I told him to open up his db and tell me what it said in the post_status column in the wp_posts table. See, in previous versions of WordPress, in order to differentiate between a post and a page, it was dependent on the post_status column. For a published post, the column had a value of “publish” and for a page it had the value “static” in the column. All of his posts and pages both had values of “publish”. So this was obviously where the problem was. But now we needed to find out where exactly an entry was defined as a post or a page. Ultimately, we got it narrowed down to the post_type column. Previously, this column wasn’t used at all, at least from what I could see. So now, in order to differentiate between a post and a page, a post gets the value post_type=”post” and a page gets post_type=”page”. Makes you wonder why it didn’t do this in the first place!

I’m sure this affects a lot of plugins; I know it affects my Ask Me plugin!

8 Responses to “WordPress 2.1 – post_type = “page””

1 Golgotha

Hey Sara, thanks for the heads up on that. I too have not upgraded. Which any tech-junkie knows starts to give you the shakes…

But, after visiting the WordPress support forums I got scared off – seems like a lot of people are having issues. I’ll wait till I have an entirely free weekend.

2 ses5909

I’m waiting a little bit too. I will probably do it in the next couple of weeks once i know must of the issues have been identified.

3 Ben Partch

Yes, I too had issues with this change. You can see it here: http://wordpress.org/support/topic/101944 There we’re some issues with my solution, but it worked for me, then Dagon was nice enough to update the plugin and all was well in my world again. ;)

4 cpradio

I didn’t have a single problem with upgrading. I do not use a lot of plugins, but the ones I do use, had no issues as of yet either.

5 John Loch

It seems there have been a number of changes that are going to impact plugins. I’m not looking forward to upgrading. Especially my latest SEOSEM bundle beta release.

Thanks for your observations re the column use. It would have been nice if it were just code changes..

Oh well, thems the breaks.

6 Joan Planas

ASK ME! is great plugin!
Please upgrade for wordpress 2.1.2

thanks!

7 ses5909

Thanks Joan. I certainly plan to.

8 Trofim

And again about this. If the search engines learn to understand the meaning, the bloggers have poizgolyatsya to be readable and do not like the others.

mulberry sale spyder womens jacket cheap new balance 574 mulberry outlet cheap new balance 574 arcteryx outlet mulberry sale spyder womens jacket mulberry sale spyder womens jacket mulberry outlet mulberry outlet new balance 574

Popular Articles

Top 10 Commentators


Subscribe to this feed! Subscribe by Email!

Random Bits Podcast

You need to download the Flash player from Adobe

Blogs Worth Reading