Archive for ‘The News’

July 13th, 2010

Controlling the number of posts in multiple loop calls on a single WordPress page

That’s kind of a mouthful, eh?

With all the talk of organizations using WordPress as their website CMS, it’s pretty surprising some features aren’t yet part of the core code or at least surprising that some hacks aren’t more distributed. A very basic feature I know every news site would want is the ability to post multiple headline stacks on one page and control how many headlines each stack displays.

I’m currently in the process of transforming a very static agency intranet homepage into something more vibrant and news-powered using WordPress and I spent an hour searching for the most fool-proof, direct way to accomplish the display of multiple categories on one page. I thought I’d pass along the best solution I’ve found.

The crux of the problem is that using multiple loops on a single page seems to affect the way each loop displays, and not in a good way. No matter how I tried to reset or rewind a loop, it just caused problems for itself, another loop or the entire page. I used WP Modder’s solution and it worked like a charm.

His usage was slightly different than mine. His setup was:

1) Pull the first few headlines from a particular category and display them in a unique way
2) Then display the rest of the headlines normally without duplicating headlines from the previously displayed category

My setup was:

1) Every post is assigned ONE category
2) Every category will display X number of headlines on the front page and that number will vary depending on the category

To accomplish that, you replace this in every instance of your loop:

1
<?php while  ( have_posts() ) : the_post() ?>

… with this:

1
2
<?php $my_query = new WP_Query('category_name=My Badass Category&showposts=3');
while ($my_query->have_posts()) : $my_query->the_post(); ?>

… obviously replacing the category name and the number of posts to show. Using the same query name multiple times for this purpose may not be kosher, but it works and my page isn’t broken, so I’m sticking with it. Of course, most news sites would assign multiple categories to a post, but, uh, that’s your problem. :)

December 2nd, 2009

Mapping the manhunt

After four Lakewood police officers were shot at a Forza coffee shop in Parkland on Sunday, November 29, police from Seattle and Pierce County scoured the region for the suspect, Maurice Clemmons. During the 40 or so hours following the crime, there was a dizzying amount of police activity in the region, including a failed hours-long standoff in the Leschi neighborhood of Seattle.


View Manhunt! in a larger map

I live in the nearby neighborhood of Mount Baker and was on news-junky high alert as helicopters circled Seattle’s central area all night long. After the police came up empty from the standoff in Leschi, they headed to Beacon Hill and Columbia City on separate tips, both neighborhoods that border mine on the south side.

Because it had become a national story at this point, family members and friends of mine in other states were asking how far away the police activity was happening from where I lived, so I created a simple Google map to show them. After I sent the link, it occurred to me none of the stories online were using a map to tell this particular story yet. So I kept adding to it from what I was learning on news sites, the police scanner and Twitter via the #washooting hash tag. Local media big and small started taking notice of the map, linked to it and traffic started pouring in.

googlemap

Two things this unintentional experiment taught me about breaking news online:

1) People crave simplicity when things get complicated. There will always be a need for someone to distill information and make sense of it. I think maps, in general, are overused in the news business. But in this case – with this story – it couldn’t be told without a map. Seattle residents were worried about the police activity and having a suspected murderer on the loose. They wondered when it might affect their neighborhood or when it might stop affecting their neighborhood. There was an overwhelming amount of information out there, but scattered in a hundred different places, and not everybody has the patience to sift through all of it.

Side note: The best use I’ve seen of this type of breaking news via Google map came from the San Diego Union-Tribune in 2007 with their wildfire map. Another instance where residents felt surrounded by the news and needed to make visual sense of what was happening.

2) West Seattle Blog must get a SICK amount of traffic. At least half of the traffic sent to the map came from West Seattle Blog. Local advertisers would be crazy not to get their businesses on that blog asap.

March 27th, 2009

And finally tonight …

… a collection of TV news stories about people finding images of Jesus or the Virgin Mary in their toast, leg injuries, cat’s fur, what have you.