Using new WP_Query in shortcode in a custom field causes the main post content to not display

You’re using get_posts which returns an array of posts, which you can loop through using foreach, but not the_loop. Try this version of the code: function ia_news_display_test($atts){ // [ia_news cat=”category” num=’numbertodisplay’] extract(shortcode_atts(array( ‘cat’ => ‘any’, ‘num’ => ‘2’, ), $atts)); $dirloop = new WP_Query( array( ‘post_type’ => ‘ia_news’, ‘category_name’ => $cat, ‘posts_per_page’ => $num, ‘orderby’ … Read more

List all posts in Custom Post Type but group dynamically by Custom Taxonomies

Try this piece of code for page template. I’ve used it on one of my projects. It outputs taxonomy term one by one with list of all posts with this term. (Just replace YOUR_TAXONOMY_SLUG to yours) <div id=”content”> <h2 class=”entry-title”><?php the_title(); ?></h2> <div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>> $mytaxonomy = get_terms(‘YOUR_TAXONOMY_SLUG’, array(“fields” => “names”)); … Read more

Alphabetical sorting of custom post type – one letter per page

Building the navigation is pretty straight forward. You have a few possibilities afterwards, I’d suggest you build one page template and use a GET-parameter to sort it out. using a GET variable Your Links in the navigation would be like: http://www.example.com/yourpage?letter=a In the page template you make a simple query in the wpdb. global $wpdb; … Read more

Custom taxonomy template loop

The way I read you question is that you need 12 posts per page in this taxonomy regardless of the current term been displayed. This can be easily done with pre_get_posts. You should never change the main query for a custom query on archive pages. Have a read on this answer I’ve recently done on … Read more

meta_query not working properly

Based on the codex, the meta_query parameter contains one or more array with the relation parameter not set if single inner meta_query array. Also remove the page parameter as it serves only for a Static Front Page. Your args array should look like that: $archive_args = array( ‘post_type’ => ‘speight_home_plans’, ‘orderby’=> ‘title’, ‘order’ => ‘ASC’, … Read more

Show all custom post type posts sorted by custom taxonomy then by another custom taxonomy

First get a list of categories and a list of locations. Then loop through each category. Within each category loop through the list of locations and query posts that have the current category and the current location and output the list: $categories = get_terms( array( ‘taxonomy’ => ‘shop_category’, ) ); $locations = get_terms( array( ‘taxonomy’ … Read more