Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress: Multiple loops or 1 loop with multiple display options? Re: WordPress: Multiple loops or 1 loop with multiple display options?

#103138
evilplan
Member

Hi Senff. Thanks for a thoughtful response :)

The way I’ve done the loop seems to work fine, which made me suspicious haha. I actually think that even with Chris and co’s brilliant work on WordPress, there’s still a bit of mystery about the loop. I was stumped for ages, if I’m honest! Your comment about looping through 10 posts, changing my markup depending upon what it’s doing, is the way I *think* I should do it – but it actually means more code. It would make much more sense once it’s complete, but I suspect I’d get fed up before then.

When it comes to point 2, I’m actually not doing any measurement. I’m simply DIVing it up and including an :after bit of clear:both stuff to draw the div down.

By doing that, the containing div is already as tall as the tallest element, so I don’t even have to care about box sizes.

But it still seems a bit unprofessional! When I read your comment about it, it made much more sense than my thinking. But maybe this is “newbie’s curse”: Assuming that my simple solution must somehow not be right.

Given what I’ve said – that I just do a div, with 2 divs inside it, floated left and 46% wide, for the title, then a clearfix, then a div with 2 divs inside it etc for the excerpt, and this lines everything up without me using any height specified, do you think I should do more to *guarantee* the height of the boxes? I guess my instinct is “if it works with the bare minimum of code, don’t add more”. But:

I’m intrigued by your suggestion about JQuery. I’ve been avoiding it, but suddenly yesterday I realised the beauty of JQuery and plan to learn it (and use it wisely!). If you could give me a little more information about what I might want to do to check for element sizes, I’d be really grateful. I’m not asking for code, just something to make me think.

I’m very new to this, as I’ve said, and I’m so grateful for the community out there. That’s the real benefit of open-source: The mindset that goes with it, the willingness to share. I’m in my 40s and a manual worker, so this is a completely new thing for me.

I’m having an absolute ball playing with it though.

Yesterday I finally cracked something I’ve been trying to do for ages – on the front page, where you have your excerpts and, say, “24 comments”, I’ve always wanted it to tell me how many unread comments there are and to offer me a link to take me to the first unread comment.

I guess I spent 20 hours coding it in total, but I cracked it and I’m so happy. The test site now says “24 comments (11 unread)”, and if you click on the “11 unread” you get taken to the first unread post. I’ve seen plugins that will add a CSS class to it, but I wanted a front-page display item. My one adds a cookie showing the last post displayed, and when you visit the home page it quickly loops through the comment ID for each excerpt displayed, pulls out the URL for the first unread one and serves it up as a link. My plan is to add a “bookmark” link under each comment (the site can get hundreds of comments – it’s a political site) with JQuery/Ajax, if I can ever get my head around it, because the unread comment count assumes that if you displayed the page, you read all the comments. I want the user to have more control.

Stuff like that, and the backup and inspiration provided by you guys, is making me want to dig in even more. I’m spending loads of time on the redesign, because the (very busy) blog is run by a friend who was still on WordPress 2.3 with the old v1.5 default theme – so the stuff I’m adding is a lot of fun.

Thanks again – even if I end up doing this wrong, your post has given me a bit of confidence that I’m on the right track. Once the site is more than a playground and I can upload it to a public server for testing, I’ll post the link in here. You’ll all probably hate the politics (we’re all British left-wingers!) but I wanna make it a design to be proud of.