WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my site I want to add a section just below Navigation and above-content (from where posts starts to show up on front page) which would show a panel where I can put any BREAKING NEWS (not always, whenever I want) with its excerpt and image. That panel should stretch with max-width.

I want to pull that BREAKING NEWS from a specific category say - category_breaking.

Is it possible? If yes, then how?

Thanks for the help.

I want to achieve exactly like this - (http://i.imgur.com/4D9kE.png)

share|improve this question
up vote 2 down vote accepted

It's certainly possible, and is a common thing to do with WordPress:

  $q = new WP_Query('category_name=category_breaking'); // query that gets all posts in category "category_breaking"
  if( $q->have_posts() ) : // if there are posts returned by query...
    echo "<div id='breaking_news'>"; // start the breaking news section
    while( $q->have_posts() ) : $q->the_post(); // start looping through query results
      echo "<div class='bn_post'>"; // single breaking news post start
      echo "<h2>".get_the_title()."</h2>"; // display breaking news post title
      if(has_post_thumbnail()) // if post has featured image set...
        the_post_thumbnail(); // then display featured image
      echo "</div>"; // close single breaking news post
    echo "</div>"; // close breaking news section
share|improve this answer
Well, you made it sound so simple. I would be applying that asap and would let you know. :) – vajrasar Aug 21 '12 at 20:30
well, after using your help and forking it a bit with the help of various forums. I came to wrap it up with what I need. Thanks. This is the final code I used, which is working fine. dpaste.com/hold/790904 – vajrasar Aug 24 '12 at 8:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.