WordPress Pages and Babysitting Rikuto

What did I do today?

I made a math worksheet about bus timetables, then I spent the rest of the day babysitting Rikuto while his mum was at work. We watched some Olympic volleyball, then played in the street on his little Thomas the Tank Engine train.

Rikuto is suffering from diarrhea at the moment which means after holding him for a while, my arms smell of poo.

What did I learn today?

global $post;
if(is_page() && $post->post_parent) {
     echo "do something";
}

That little conditional works on WordPress. If you paste it into a page template, you can determine whether or not the page is a parent or child. It’s really saying, “If this is a page and it has a parent, it must be a child so (do something)”.

What did you learn today?

If you like, you can find me on Twitter at @nick_ramsay. I'd love to hear from you!

12 thoughts on “WordPress Pages and Babysitting Rikuto

  1. OK so your title sounded promising, i.e. “poo” but then I read it and it kind of made no sense. Well maybe it makes sense but the code is kind of wacky. Have you been smoking wacky tabacky???

    1. The title accurately matched the content of the post. I wrote about child and parent WordPress pages, and how my son has diarrhea. Though, for you, I’ll make the titles more obvious from now on.

      The code is PHP. There’s nothing wacky about it. I happened to find it very useful and wanted to share it.

    1. Definition of “bra”:

      The shortened word for brassiere. A woman’s close-fitting undergarment which is worn to support and give contour to the breasts.

      You’re either calling me a support garment, or this is some new bizarre Canadian slang.

  2. Dude, you being in Japan has really distanced you from all of the cool expressions from tv shows such as “Dog, the bounty hunter.” Instead of saying bro, as in “brother,” he says “bra.” OK bra???

  3. Hi Nick!
    I like this post (and I liked the original name, but either way…)

    I am glad to see you blogging about php code and other things that only the truly nerd (i.e. us) care about.
    So now if I start to ramble on DailyJ about the early history of the internet, linux, and other nerd-fare I won’t feel so bad. Nick started it 🙂

Comments are closed.