In for a penny..

So, matt has just noticed my post about how WordPress is billed as a ‘blog’ or ’state-of-the-art semantic personal publishing platform’ (if you like extensive terminology) yet has “the knock-down power of the yin-yang” (as Burt Gummer would say).

Now, I do not know if he was gently ‘extracting the michael’ or not but it’s interesting that he would say ‘He caught us’. I caught them?

I feel all warm and fuzzy, matt. :)

WordPress is more than just blog software, or even a ‘personal publishing platform’ for that matter. My goal was to point out the strengths that WP and the community behind it has and perhaps illustrate that with examples of code.

I’m not sure if the message was lost, or received. Either way it got a reaction, which has to count for something. :)

To have said post noticed by the project lead is just a little daunting.. if not extremly cool as far as ‘geek factor’ is concerned.

≡ This is a journal entry relating to the topics of , .

Brendan Borlase is a Systems and Network Administrator living in Adelaide, Australia, having lived, worked and breathed Information Technology for over 12 years. Learn more.

Feedback is encouraged. If you would like to read more, consider subscribing to the regularly updated RSS Feed.


  1. Phu

    The first hint that Matt found your post was the sudden spike in traffic that I received from you:-)

  2. brendan

    “The first hint that Matt found your post was the sudden spike in traffic”

    It’s like being slashdot’d by bloggers. :)

    Your examples were my inspiration to start ripping into the code and getting to grips with it my friend, only fair that the folk visiting know that. :)

  3. Chris J. Davis

    Very nice article. For my site I am doing something akin to your set up, but going about it differently with only one loop!

    Before the loop is called:

    <?php
    $i = 0;
    ?>

    Then right after the loop:

    <?php
    $num_contents = 2;
    if ($i < $num_contents ){
    ?>

    I then place all my regular template tags. Next I throw in the code for what happens after the second post is echoed out:

    <?php $i++; ?>
    <?php if ($i == $num_contents ) echo "Some other junk"; ?>
    <?php } else { ?>
    <li class="title_previous">

    alternate content

    <?php } ?>

    Basicaly the above code is saying display $num_contents, in this case 2, in full then when you have reached your second post display the rest according to the tags defined between <?php } else { ?> and <?php } ?>

    In the above example, “Some other junk” could be a plugin call, or an include.. anything.

    You can see how I am using this on my site, the newest two posts are “Fresh Content” and then the other posts, are displayed as list items under Slightly Stale.

    I am thinking of packaging this up into a plugin, or as a custom theme template…

  4. brendan

    Chris,

    Interesting. It would certainly make a great plugin. The only hassles I had ‘counting’ in the loops is that the count always takes precedence over querys.

    I have a current problem in that I cannot create asides using a WP category of any description (I’m forced to look at plugins that create their own table), as even if it exclude it (the asides category) in a query, it still gets counted as a post (even though excluded!).

    Thus if I add any ‘asides’ as an example, using a loop, query or get_post, the remainders (in your case ’slightly stale’) end up showing the latest post as well (due to any asides being newer, although filtered out, and thus not shown are still being counted).

    I may have to do something like your doing and create the ‘hell’ loop with all processing taking place in one shot, at least then if content is excluded for whatever reason, then a counter variable read, it may make asides an option.

  5. matthew

    I have a current problem in that I cannot create asides using a WP category of any description (I?m forced to look at plugins that create their own table), as even if it exclude it (the asides category) in a query, it still gets counted as a post (even though excluded!).

    haha! Thats what mine does! I simply chose to ignore it and let the recent posts run to whatever amount they choose to. Its a bit irritating and means as well as the recent posts being a seemingly random amount, the first paged archive starts with the wrong post.
    my loop for the recent posts (its technically the 3rd loop on that page I guess - latest post, asides, recent posts)

    start loop
    if post isnt in asides
    if post is 1-5
    show the whole post
    if post is 6+
    show just the title
    go back to the start after 25 posts

    That 25 posts includes asides so if 5 of the first 25 posts are asides, it only shows 20. In fact Im not even sure it does that properly, at somepoint it just beat me I guess :-/

    does that make sense? I could post the whole awful mess of that 3rd loop?

    There is doubt an easier way to do that, but my less that logical mind cant work it out.

    If I can work it out Ill fix it, as it is its just mildly annoying.

  6. brendan

    “does that make sense?”

    Yes, in the same painful way it made sense to me when I worked out that counting loops is not overly easy, and yes while counting posts is simpler, it brings a raft of problems with it.

    If one ‘counts’ posts (in my case I just count one post forward) then no matter how one excludes certain categories (which should to my mind not be counted, after all, one wouldn’t exclude them otherwise!) all posts, excluded or not will be counted.

    Of course, trying to figure all that out at the time fried more than just a few synapses so I gave up and grabbed a plugin instead. It might be time to re-investigate that as I’d far rather use the built in WP tables etc.

    Basically I need figure out to create a conditional counter.. something that starts a counter (started at +1), and then increments said counter by 1 if the category is an aside, before dropping into a post loop that displays the results by rolling back through the posts based on the counter total..

    I swear if I write a plugin, I know it’s not customary but do_shit() and go_do_shit() strike me as amusing and memorable plugin hooks. :D

  7. matthew

    ahh, I noticed my loop thing there didnt break the lines properly :-/

    sounds like my way is similar to yours though.

    what would be great is a function
    latest post - dotheloop(showposts=1&excludecat=asides);
    asides - dotheloop(showposts=5&showcat=asides);
    older posts, with full article - dotheloop(showposts=5&startfrom=2&excludecat=asides);
    older posts, with just the title - dotheloop(showposts=5&startfrom=7&excludecat=asides);

    that also means that then the paged archives need to know where that home page ends so that they can start in the right place. Maybe an internal WP variable, Im not sure on that one

    maybe theres a way of doing this currently, but ill be buggered if i can find it. As it is Im happy-ish with my fugly work around.

    doshit() and godo_shit() seem like good hooks :-D