WordPress loop to pull 4 pages/posts by ID

Never under any circumstances use query_posts. There is no excuse. Use WP_Query instead. According to the WP_Query documentation, post_type accepts a value of ‘any’. $ids = array(2101,3754,4760,2572); $query = new WP_Query(array( ‘post_type’ => ‘any’, ‘post__in’ => $ids, ‘posts_per_page’ => 4 )); if ( $query->have_posts()) { while( $query->have_posts() ) { $query->the_post(); the_title(); // etc } wp_reset_postdata(); … Read more

Custom pagination [duplicate]

I just have modified your code a little for adding pagination…. Here you go…. It will be your custom post type loop…. <?php if ( get_query_var(‘page’) ) { $paged = get_query_var(‘page’); } else if ( get_query_var(‘paged’) ) { $paged = get_query_var(‘paged’); } ?> <?php $LoopPortfolio = new WP_Query(array( ‘post_type’ => ‘portfolio’, ‘paged’=>$paged, ‘posts_per_page’ => ‘3’ … Read more

Exclude a custom category from a list

I am puzzled at how that could possibly work, even a little. You are setting your $terms variable after you start to try to loop over it. That makes no sense. A quick rewrite would make this a little better: $html=””; $html .= ‘<ul class=”item-direct-filters”><li class=”first”><strong>view more:</strong></li>’; $taxonomy = ‘category’; $k = 0; $terms = … Read more

Get Registered Custom Post Type to get All Custom Taxonomies

Try this (tested) code below. I believe the issue was the passing of the $post_type parameter to get_object_taxonomies (i.e. you passed it in quotes as ‘$post_type’. If uncomment the two var_dump‘s you’ll see what information is outputted. <?php $postargs = array( ‘public’ => true, ‘_builtin’ => false ); $post_types = get_post_types( $postargs, ‘names’, ‘and’ ); … Read more