Changed site layout

Well, Once again, I’ve tweaked the layout slightly.

I’ve removed the frontpage, I’ve limited it to 2 posts for the front page, and a archives with only excerpts.

All pages are now impossible to get to unless you know their name.. I’ll change that with some widgets at some point.

The active colour on the header links needs changing..

I need to launch my other site

I need to get my mind together and aim to get things finished

I need to work out what exactly i’m doing…

Oh, I also got rid of Gallery2.. Seems it may’ve been causing some load issues.. All the Flood images from Kyogle Jan 08 are here: http://dd32.id.au/tag/kyogle+pics/

Goodbye fair machine..

Today is the day that I confirm i no longer own a eeePC, A few months back, I bought a 2nd hand EeePC 701 for use as a machine for general use while out and about, It got a fair bit of use as a MP3 player and GPS Navigator in the car, But it seems, unfortunately, this lead to its demise.

A few weeks back, A few days before I was to leave for WordCamp AU, I went to the beach for a Night, Was a nice break, Took the laptop with me, Worked great on the way down.

Coming home on the other hand.. Bumpy dirt road, It wasnt too long before it suddenly froze, Well.. GPS Navigation froze up at least.. Music kept playing for another hour until i finally pulled over to fix the machine.

Oddly enough, It was completely frozen, no input at all.. Reboot it.. all was fine.

Was fine the day after, Then it comes to leaving for WordCamp AU, And it refuses to turn on :( …It never regained consciousness.  (Just a sidenote, Thanks to Karloskar for the spare ram to test the ram with.. The new ram didnt help, And It lost its Warranty awhile, I bought it 2nd hand.)

Today marks the day i sold the eeePC 701, Hopefully its screen will bring life to a fellow owners eeePC who’s screen cracked.

So Goodbye Henry(For that is what i’ll call it), I’ll replace it with another unit at some stage, But not another 700 series.

I’ve contemplated the Aspire One, or the MSI Wind, But the chipset limitations of 1GB ram sticks seems utter stupidity (And i have a spare 2GB Sodim ram stick now..). The eeePC 901 looks like a nice replacement in all honesty, I was looking at non-asus items, simply for the fact I thought i’d get a better item from someone who i dont class as the market leader, but it just doesnt look like thats the case. Theres the Samsung NC10 which looks like a really nice unit, Unfortunately its not available in Australia, and i’d prefer to be able to use one before outlaying the cost..

Since January will be bringing a few developments in the netbook arena (New products from a a few manufacturers are rumored) I might wait until Feb before buying again.. Unless I see one of the above items going rather cheaply.. Theres also been talk of the price coming down on the Aspire and others.. But also talk of the cost going up in Aus thanks to the USD/AUD rate :(

..In other news I really need to start blogging more,

Its over

WordCamp Australia 2008 is over, And i’m back home now.

How was it? Great.

Go again? Yes.

Invite everyone else to come along? Hell yeah!

Unfortunately I didn’t have a chance to get some business cards printed up before WCAU,  So to those of you who asked, Sorry; Hopefully i’ll get my Portfolio website up and running shortly. (And not surprisingly, Turns out, i also had a Twitter account, Not that i understand a word of how to use it)

To all of you who i met out down there, Thanks for turning up, It was great meeting you all, Jane and Matt deserve a special mention though,  Both for the speeches and the discussion you guys provided the event with (Oh hey, Sorry for the odd introduction Matt :) – it was good to get odd reactions).

Highlight? Originally it would’ve been Matt’s speech, But (And i wish i had a photo of this) was the reason for the dodgy wireless coverage, Some of you will know it was due to a wireless router not working correctly (which was on Matt’s table too). The reason the router wasn’t routing? It wasn’t plugged in! When pulling up the network cables later Sunday evening, I found out that someone had forgotten to crimp the other end of the network cable, so it wasn’t actually plugged into the network.. Oops indeed..

Onto more pressing issues, At a small meeting afterwards to discuss the future of the WordCamp Australia Association, The idea of smaller meet ups was brought up,  Personally i’d like to see something happen in the Brisbane/Gold Coast area, Any takers? Not a full weekend event, Not even a day event, Just a gathering for lunch or something similar, If we can get up a good enough group of people together from the area, It might be possible to get WordCamp Australia in Brisbane for 2010 (2009 will likely be Sydney again).

So, If anyone is in the Northern Rivers district/lower QLD and up for catching up at any stage give me a yell, and we’ll see what can be organised.

Finally, To whoever is organising the BuddyPress WordCamp install, Hurry up and get it done :) Traveling home isn’t a good excuse!

The problems of get_posts() and custom post_type’s

Allright, Generally i’d not complain, I’d just make up a new Trac ticket and patch it.. But i’m seriously sick of this defect of WP_Query, A number of times i’ve just given up attempting to achieve my goal and doing it some other method which wouldnt involve hacking up everything..

The problem?

Add a new record to the WP_Posts table, with a custom post_type, now try to retrieve that post. Ah, I hear you say “Thats Easy! Just pass post_type to get_posts()” WRONG!,
Well, yes, In an ideal world, that would be the case, But no, not in this case.

First, Lets add an actual record:

[sourcecode language="php"]
$url = ‘http://dd32.id.au/';
$content = ‘DD32 is awesome!';
$datas = array(‘post_type’ => ‘custom_type’, ‘post_status’ => ‘custom_status’, ‘post_title’ => $url, ‘post_name’ => $url, ‘guid’ => md5($url), ‘post_content’ => $content);
wp_insert_post($datas);
[/sourcecode]

What have i done? Just inserted a stock standard post of type ‘custom_type’ with a non-standard status. Nothing odd there.

Now, Lets retrieve that post.

First thing, Lets check that get_posts() can handle a custom post_type:

[sourcecode language="php"]
var_dump( get_posts( array(‘post_type’ => ‘custom_type’) ) );

array
empty
[/sourcecode]

Allright, That didnt work, Better check the query used:

[sourcecode language="sql"]SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = ‘custom_type’ AND (wp_posts.post_status = ‘publish’) ORDER BY wp_posts.post_date DESC LIMIT 0, 5[/sourcecode]

Ah, It doenst like our post_status, Not a probblem, Letslet it load all status types:

[sourcecode language="php"]
var_dump( get_posts( array(‘post_type’ => ‘custom_type’, ‘post_status’ => ‘any’) ) );

array
0 =>
object(stdClass)[132]
public ‘ID’ => string ‘571’ (length=3)
public ‘post_author’ => string ‘2’ (length=1)
public ‘post_date’ => string ‘2008-11-12 16:47:06′ (length=19)
public ‘post_date_gmt’ => string ‘2008-11-12 05:47:06′ (length=19)
public ‘post_content’ => string ‘DD32 is awesome!’ (length=16)
public ‘post_title’ => string ‘http://dd32.id.au/’ (length=18)
public ‘post_category’ => string ‘0’ (length=1)
public ‘post_excerpt’ => string ” (length=0)
public ‘post_status’ => string ‘custom_status’ (length=13)
public ‘comment_status’ => string ‘open’ (length=4)
public ‘ping_status’ => string ‘open’ (length=4)
public ‘post_password’ => string ” (length=0)
public ‘post_name’ => string ‘httpdd32idau’ (length=12)
public ‘to_ping’ => string ” (length=0)
public ‘pinged’ => string ” (length=0)
public ‘post_modified’ => string ‘2008-11-12 16:47:06′ (length=19)
public ‘post_modified_gmt’ => string ‘2008-11-12 05:47:06′ (length=19)
public ‘post_content_filtered’ => string ” (length=0)
public ‘post_parent’ => string ‘0’ (length=1)
public ‘guid’ => string ‘9b159fde538e1d5b84949ae427f50168′ (length=32)
public ‘menu_order’ => string ‘0’ (length=1)
public ‘post_type’ => string ‘custom_type’ (length=11)
public ‘post_mime_type’ => string ” (length=0)
public ‘comment_count’ => string ‘0’ (length=1)
[/sourcecode]

Looks good to me, Everything seems to have been set correctly.

However, hang on, What happens when i only want to retrieve a specific item? Well, I guess we need to specify some arguements to retrieve a single record:

[sourcecode language="php"]
var_dump( get_posts( array(‘post_type’ => ‘custom_type’, ‘post_status’ => ‘any’, ‘p’ => 571 ) ) );
var_dump( get_posts( array(‘post_type’ => ‘custom_type’, ‘post_status’ => ‘any’, ‘page_id’ => 571 ) ) );
var_dump( get_posts( array(‘post_type’ => ‘custom_type’, ‘post_status’ => ‘any’, ‘name’ => $url ) ) );
var_dump( get_posts( array(‘post_type’ => ‘custom_type’, ‘post_status’ => ‘any’, ‘pagename’ => $url ) ) );
[/sourcecode]

One of those should return something.. Right? Well.. Lets look:

[sourcecode language="php"]
array
empty
array
empty
array
empty
array
empty
[/sourcecode]

Nope, Not a thing.. What the?

Lets go check those queries again…

[sourcecode language="sql"]
8 =>
array
0 => string ‘ SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.ID = 571 AND wp_posts.post_type = ‘post’ ORDER BY wp_posts.post_date DESC ‘ (length=135)
1 => float 0.000998020172119
2 => string ‘get_posts’ (length=9)
9 =>
array
0 => string ‘ SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.ID = 571 AND wp_posts.post_type = ‘page’ ORDER BY wp_posts.post_date DESC ‘ (length=135)
1 => float 0.00107502937317
2 => string ‘get_posts’ (length=9)
10 =>
array
0 => string ‘ SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_name = ‘httpdd32idau’ AND wp_posts.post_type = ‘post’ ORDER BY wp_posts.post_date DESC ‘ (length=153)
1 => float 0.00149297714233
2 => string ‘get_posts’ (length=9)
11 =>
array
0 => string ‘SELECT ID, post_name, post_parent FROM wp_posts WHERE post_name = ‘dd32idau’ AND (post_type = ‘page’ OR post_type = ‘attachment’)’ (length=129)
1 => float 0.00108218193054
2 => string ‘get_page_by_path’ (length=16)
12 =>
array
0 => string ‘SELECT ID, post_name, post_parent FROM wp_posts WHERE post_name = ‘dd32idau’ AND (post_type = ‘page’ OR post_type = ‘attachment’)’ (length=129)
1 => float 0.000935077667236
2 => string ‘get_page_by_path’ (length=16)
13 =>
array
0 => string ‘ SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND (wp_posts.ID = ‘0’) AND wp_posts.post_type = ‘page’ ORDER BY wp_posts.post_date DESC ‘ (length=137)
1 => float 0.000837087631226
2 => string ‘get_posts’ (length=9)
[/sourcecode]

Well, Let me first say, No idea why the last case has caused 3 queries (which are near unique), But thats not the interesting part.. Notice the post_type? Its no longer set to our requested ‘custom_type‘ oops, Lets go back and check that code, Wait! I did specify it!.

Eugh. Thank you WP_Query, Of course you know better than I do, Sorry i questioned your judgement and requested something else!

Time to hook in and tell WP_Query I know best..

[sourcecode language="php"]
function stupid_post_type_custom_type($query) {
if ( isset($query->query_vars['post_type']) && ‘custom_type’ == $query->query_vars['post_type'] )
$query->is_page = $query->is_single = $query->is_attchment = false;
}
$url = ‘http://dd32.id.au/';

add_action(‘parse_query’, ‘stupid_post_type_custom_type’, 10, 1);
var_dump( get_posts( array(‘post_type’ => ‘custom_type’, ‘post_status’ => ‘any’, ‘p’ => 571 ) ) );
var_dump( get_posts( array(‘post_type’ => ‘custom_type’, ‘post_status’ => ‘any’, ‘page_id’ => 571 ) ) );
var_dump( get_posts( array(‘post_type’ => ‘custom_type’, ‘post_status’ => ‘any’, ‘name’ => $url ) ) );
var_dump( get_posts( array(‘post_type’ => ‘custom_type’, ‘post_status’ => ‘any’, ‘pagename’ => $url ) ) );
remove_action(‘parse_query’, ‘stupid_post_type_custom_type’, 10, 1);
[/sourcecode]

WooHoo!

[sourcecode language="php"]
array
0 =>
object(stdClass)[131]
public ‘ID’ => string ‘571’ (length=3)
public ‘post_author’ => string ‘2’ (length=1)
public ‘post_date’ => string ‘2008-11-12 16:47:06′ (length=19)
public ‘post_date_gmt’ => string ‘2008-11-12 05:47:06′ (length=19)
public ‘post_content’ => string ‘DD32 is awesome!’ (length=16)
public ‘post_title’ => string ‘http://dd32.id.au/’ (length=18)
public ‘post_category’ => string ‘0’ (length=1)
public ‘post_excerpt’ => string ” (length=0)
public ‘post_status’ => string ‘custom_status’ (length=13)
public ‘comment_status’ => string ‘open’ (length=4)
public ‘ping_status’ => string ‘open’ (length=4)
public ‘post_password’ => string ” (length=0)
public ‘post_name’ => string ‘httpdd32idau’ (length=12)
public ‘to_ping’ => string ” (length=0)
public ‘pinged’ => string ” (length=0)
public ‘post_modified’ => string ‘2008-11-12 16:47:06′ (length=19)
public ‘post_modified_gmt’ => string ‘2008-11-12 05:47:06′ (length=19)
public ‘post_content_filtered’ => string ” (length=0)
public ‘post_parent’ => string ‘0’ (length=1)
public ‘guid’ => string ‘9b159fde538e1d5b84949ae427f50168′ (length=32)
public ‘menu_order’ => string ‘0’ (length=1)
public ‘post_type’ => string ‘custom_type’ (length=11)
public ‘post_mime_type’ => string ” (length=0)
public ‘comment_count’ => string ‘0’ (length=1)
array
0 =>
object(stdClass)[133]
public ‘ID’ => string ‘571’ (length=3)
public ‘post_author’ => string ‘2’ (length=1)
public ‘post_date’ => string ‘2008-11-12 16:47:06′ (length=19)
public ‘post_date_gmt’ => string ‘2008-11-12 05:47:06′ (length=19)
public ‘post_content’ => string ‘DD32 is awesome!’ (length=16)
public ‘post_title’ => string ‘http://dd32.id.au/’ (length=18)
public ‘post_category’ => string ‘0’ (length=1)
public ‘post_excerpt’ => string ” (length=0)
public ‘post_status’ => string ‘custom_status’ (length=13)
public ‘comment_status’ => string ‘open’ (length=4)
public ‘ping_status’ => string ‘open’ (length=4)
public ‘post_password’ => string ” (length=0)
public ‘post_name’ => string ‘httpdd32idau’ (length=12)
public ‘to_ping’ => string ” (length=0)
public ‘pinged’ => string ” (length=0)
public ‘post_modified’ => string ‘2008-11-12 16:47:06′ (length=19)
public ‘post_modified_gmt’ => string ‘2008-11-12 05:47:06′ (length=19)
public ‘post_content_filtered’ => string ” (length=0)
public ‘post_parent’ => string ‘0’ (length=1)
public ‘guid’ => string ‘9b159fde538e1d5b84949ae427f50168′ (length=32)
public ‘menu_order’ => string ‘0’ (length=1)
public ‘post_type’ => string ‘custom_type’ (length=11)
public ‘post_mime_type’ => string ” (length=0)
public ‘comment_count’ => string ‘0’ (length=1)
array
0 =>
object(stdClass)[133]
public ‘ID’ => string ‘571’ (length=3)
public ‘post_author’ => string ‘2’ (length=1)
public ‘post_date’ => string ‘2008-11-12 16:47:06′ (length=19)
public ‘post_date_gmt’ => string ‘2008-11-12 05:47:06′ (length=19)
public ‘post_content’ => string ‘DD32 is awesome!’ (length=16)
public ‘post_title’ => string ‘http://dd32.id.au/’ (length=18)
public ‘post_category’ => string ‘0’ (length=1)
public ‘post_excerpt’ => string ” (length=0)
public ‘post_status’ => string ‘custom_status’ (length=13)
public ‘comment_status’ => string ‘open’ (length=4)
public ‘ping_status’ => string ‘open’ (length=4)
public ‘post_password’ => string ” (length=0)
public ‘post_name’ => string ‘httpdd32idau’ (length=12)
public ‘to_ping’ => string ” (length=0)
public ‘pinged’ => string ” (length=0)
public ‘post_modified’ => string ‘2008-11-12 16:47:06′ (length=19)
public ‘post_modified_gmt’ => string ‘2008-11-12 05:47:06′ (length=19)
public ‘post_content_filtered’ => string ” (length=0)
public ‘post_parent’ => string ‘0’ (length=1)
public ‘guid’ => string ‘9b159fde538e1d5b84949ae427f50168′ (length=32)
public ‘menu_order’ => string ‘0’ (length=1)
public ‘post_type’ => string ‘custom_type’ (length=11)
public ‘post_mime_type’ => string ” (length=0)
public ‘comment_count’ => string ‘0’ (length=1)
array
empty
[/sourcecode]

Wait!, Why is that last case still returning nothing?

Query time again..

[sourcecode language="sql"]
8 =>
array
0 => string ‘ SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.ID = 571 AND wp_posts.post_type = ‘custom_type’ ORDER BY wp_posts.post_date DESC ‘ (length=142)
1 => float 0.00179696083069
2 => string ‘get_posts’ (length=9)

11 =>
array
0 => string ‘ SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.ID = 571 AND wp_posts.post_type = ‘custom_type’ ORDER BY wp_posts.post_date DESC ‘ (length=142)
1 => float 0.000961065292358
2 => string ‘get_posts’ (length=9)
12 =>
array
0 => string ‘ SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_name = ‘httpdd32idau’ AND wp_posts.post_type = ‘custom_type’ ORDER BY wp_posts.post_date DESC ‘ (length=160)
1 => float 0.00102686882019
2 => string ‘get_posts’ (length=9)
13 =>
array
0 => string ‘SELECT ID, post_name, post_parent FROM wp_posts WHERE post_name = ‘dd32idau’ AND (post_type = ‘page’ OR post_type = ‘attachment’)’ (length=129)
1 => float 0.00131893157959
2 => string ‘get_page_by_path’ (length=16)
14 =>
array
0 => string ‘SELECT ID, post_name, post_parent FROM wp_posts WHERE post_name = ‘dd32idau’ AND (post_type = ‘page’ OR post_type = ‘attachment’)’ (length=129)
1 => float 0.00103116035461
2 => string ‘get_page_by_path’ (length=16)
15 =>
array
0 => string ‘ SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND (wp_posts.ID = ‘0’) AND wp_posts.post_type = ‘custom_type’ ORDER BY wp_posts.post_date DESC ‘ (length=144)
1 => float 0.00140690803528
2 => string ‘get_posts’ (length=9)
[/sourcecode]

Ok, Seems using ‘pagename’ query parameter just isnt going to work, It’s been hard coded to work off ‘page’ or ‘attachment’ regardless, And when it finally does fall through to using custom_type.. It’s forgotten it was using pagename, and instead, is trying to use an ID..

Moral of the story? the parse_query hook is your friend; But make sure to only modify those queries which you’re using, and not all the core WP_Query queries too..

The working code:

[sourcecode language="php"]
function stupid_post_type_custom_type($query) {
if ( isset($query->query_vars['post_type']) && ‘custom_type’ == $query->query_vars['post_type'] )
$query->is_page = $query->is_single = $query->is_attchment = false;
}
$url = ‘http://dd32.id.au/';

add_action(‘parse_query’, ‘stupid_post_type_custom_type’, 10, 1);
var_dump( get_posts( array(‘post_type’ => ‘custom_type’, ‘post_status’ => ‘any’, ‘name’ => $url ) ) );
remove_action(‘parse_query’, ‘stupid_post_type_custom_type’, 10, 1);
[/sourcecode]

EDIT: ARGH. Ok, WP/the Syntax Highlighter plugin have had a war, They dont like the idea of not touching stuff within the sourcecode shortcode.. I’m pretty sure i had a Trac ticket for that….