i have a theme where first a featured post is displayed. then there is a grid of posts. Problem is grid also displays the featured post. So, featured post appears twice.

Question is how to hide featured post from grid?

Note that a custom meta box has been added to mark post/page as featured.

loop that starts featured section is as below...

if ($featured->have_posts()): while($featured->have_posts()): $featured->the_post(); ?>

grid is formed from below code... (i need to hide featured post from this grid)

$counter = 1;

$grids = 3;

global $query_string;

query_posts($query_string . '&caller_get_posts=1&posts_per_page=12&cat=-' . get_cat_ID( 'News' ));

if(have_posts()) :  while(have_posts()) :  the_post(); 
  • Have you tried the theme author's support? – Andy Macaulay-Brook Sep 21 '16 at 16:40
  • @AndyMacaulay-Brook its not purchased theme. from static html to wordpress conversion. – Kishor Parmar Sep 21 '16 at 16:46
  • Ah sorry. My misunderstanding. – Andy Macaulay-Brook Sep 21 '16 at 16:47
  • @AndyMacaulay-Brook tried $featured in query post. not working. – Kishor Parmar Sep 21 '16 at 18:29

wp section of stackexchange really seems half dead.

you rarely get issue sorted.

have_posts checks whether there is any post, so add another condition that checks whether the post is featured or not.

if(have_posts()) :  while(have_posts()) :  the_post();

replace above with below

if(have_posts() && the_post() != $featured) :  while(have_posts()) :  the_post(); 

caller_get_posts is deprecated since version 3.1!

Use ignore_sticky_posts instead. Read More

And don't use query_post it's not a good practice, When should you use WP_Query vs query_posts() vs get_posts()?

  • i think that is a suggestion for better coding and not an answer. – Kishor Parmar Sep 21 '16 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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