Exclude sub sub categories from displaying in the archive page

/* exclude sons */ $_categories = get_categories(array( ‘child_of’ => 16)); $exclude=””; foreach($_categories as $category){ $_exclude .= ‘-‘.$category->term_id.’,’; } $_exclude = substr($_exclude,0,-1); $_cats = $cat.’,’.$_exclude; query_posts(array( ‘cat’ => $_cats )); while ( have_posts() ) : the_post(); …… endwhile;

Index.php is ordering posts strangely

You shouldn’t modify the main query like that. Instead, make a secondary loop: // The Query $args = array( ‘post_status’ => ‘publish’, ‘post_type’ => ‘post’, ‘orderby’ => ‘date’, ‘order’ => ‘desc’, ); $the_query = new WP_Query( $args ); // The Loop if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); // Do output … Read more

Trying hard but can’t hide featured post/page from grid

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

Query multiple post of which one by taxonomy

I solved my problem by automatically adding the tag ‘light’ to all my projects. And then query all the post and projects with the light tag like this: Query post by taxonomy tag ‘light’: $args = array( ‘post_type’ => array( ‘projects’ , ‘post’ ), ‘tax_query’ => array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘post_tag’, ‘field’ … Read more