Show all post types in the same table of posts [duplicate]

Yes of course, if you set the query argument ‘post_type’ to ‘any’, it will retrieve any type except revisions and types with ‘exclude_from_search’ set to true. Example: $all_posts = get_posts( array( ‘post_type’ => ‘any’ ) ); Otherwise, if you don’t want ALL post types, just certain ones: $specific_posts = get_posts( array( ‘post_type’ => array( ‘movies’, … Read more

Select custom post by meta value

I think you mean a query like this one: $args = array( ‘post_type’ => ‘foo’, ‘meta_key’ => ‘bar’, ‘meta_value’ => ‘pineapple’, ‘posts_per_page’ => 1, ); $query = new WP_Query( $args ); You can check out further information here on meta queries in WP_Query. If you only want to check if there exists such a post, … Read more

How to bring custom meta boxes to custom post types?

You can do something like this: function wpse_61041_add_custom_box() { //Place your custom post types in the array $post_types = array ( ‘post’, ‘page’, ‘another_custom_post_type’ ); //Then loop through all post types and add meta boxes to them foreach( $post_types as $post_type ) { add_meta_box( ‘wpse_61041_sectionid’, ‘Does this page is in Englsih?’, ‘wpse_61041_inner_custom_box’, $post_type, ‘side’, ‘high’ … Read more

Pagination not working with custom loop

I’ve run into this problem with PageNavi before. My solution is to hijack the $wp_query variable temporarily and then reassign it after closing the loop. An exmaple: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args=array( ‘post_type’=>’post’, ‘cat’ => 6, ‘posts_per_page’ => 5, ‘paged’=>$paged ); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query($args); /* … Read more

how to add pagination and post query in taxonomy-taxonomy-term.php? [duplicate]

The problem is that you’re not letting the template file do what it is intended to do. Instead of outputting the default loop, you’re ignoring the default loop, and outputting a custom query loop. Replace all this: <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); if(!empty($wp->query_vars[‘term’])){ $terms = $wp->query_vars[‘term’]; $taxonomy = ‘term’; } … Read more

Pagination URL order

Well this seems to fix it. Not sure if this is the best way to do it so please enlighten me if I’m wrong: By changing: if ( $wp_rewrite->using_permalinks() ) $pagination[‘base’] = user_trailingslashit( trailingslashit( remove_query_arg( ‘s’, get_pagenum_link( 1 ) ) ) . ‘page/%#%/’, ‘paged’ ); to: if ( $wp_rewrite->using_permalinks() ) $_SERVER[‘REQUEST_URI’] = user_trailingslashit( trailingslashit( remove_query_arg( … Read more

Post_per_page -1 returns only half the results

As hinted by the comments I replaced the query_posts by a WP_Query query. $args=array( ‘post_type’ => ‘restaurante’, ‘posts_per_page’ => -1, ‘meta_key’ => ‘restaurante_municipio’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’); $the_query = null; $the_query = new WP_Query($args); if ( $the_query->have_posts() ) { $total_results = $the_query->found_posts; echo ‘<p><b>Restaurantes: ‘.$total_results.'</b>’; while ( $the_query->have_posts() ) { $the_query->the_post(); … .. … Read more

Custom Post within a custom post

Okay the answer is simple (was able to fix this myself). What you need to do is put another directory (let’s call it C) where the rewriting rules will be made. So for post type B, it would be: $args = array( // … other args removed for clarity ‘rewrite’ => array( ‘slug’ => ‘A/C/B’ … Read more