Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 - (

share|improve this question

1 Answer 1

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. – 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.