Exclude post format from get_posts

You just need to set the operator parameter to ‘NOT IN’ (see Codex on tax queries). Untested, but for your purposes: $args = array( ‘post_type’=> ‘post’, ‘post_status’ => ‘publish’, ‘order’ => ‘DESC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_format’, ‘field’ => ‘slug’, ‘terms’ => array( ‘post-format-aside’ ), ‘operator’ => ‘NOT IN’ ) ) );

Both a page loop and posts loop on the same page

Change: foreach ($posts_array as $monster_news) { setup_postdata($monster_news); To: foreach ($posts_array as $post) { setup_postdata($post); It seems setup_postdata() actually doesn’t modify $post itself (which was news to me). PS also loose empty , in array… I am not sure how it actually works for you with that.

get_the_category listing in hierarchial order

Use wp_list_categories instead, <?php $args = array( ‘hierarchical’ => true, ‘child_of’ => 42, //parent category ‘hide_empty’ => 1, //hide empty categories (set to 0 to show) ); wp_list_categories($args); ?> A full list of parameters for wp_list_categories can be found HERE As you can see its highly customizable simply by adding extra arguements to the array … Read more

WordPress | Date not always appear [duplicate]

Use get_the_date() instead, here’s note from the_date() codex page regarding the issue: When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date()). To repeat the date for posts published under the same day, you should use … Read more

Added if statement to loop

Try the following: if ( have_posts() ) { while( have_posts() ) { the_post(); if ( ‘reviews’ === get_post_type( get_the_ID() ) { echo ‘I am a post of the post type &rdquo;reviews&ldquo;’; // We’re done here, continue to next post continue; } // Do other stuff } } EDIT In case you’re not sure if you … Read more

How to insert category list into post creation page, and retrieve chosen categories?

By default page post type doesn’t support category taxonomy. But you can easily fix it by register category taxonomy for page post type: add_action( ‘init’, ‘wpse8170_init’ ); function wpse8170_init() { register_taxonomy_for_object_type( ‘category’, ‘page’ ); } Now you will see categories meta box in the same place as you see it at post creation page. To … Read more

How to order posts in an arbitrary order?

First off, query_posts is terrible doesn’t use it. It does all kinds of fun things like mess up the very useful conditional tags like is_singular and the like as well as mess up pagination. Short of hooking into the posts_orderby filter and writing some custom order by SQL, your best bet is to use the … Read more

How do I automate multiple category loops?

You get all categories with: $categories = get_categories( array ( ‘fields’ => ‘ids’ ) ); This returns an array with all categories. Then you should use get_posts() or a new WP_Query, because query_posts() has many side-effects and should not be used anymore. Sample code, as illustration: $categories = get_categories( array ( ‘number’ => 5 ) … Read more