Custom Post Types not showing, custom WP_Query
please try this: <?php if( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> Thank you
please try this: <?php if( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> Thank you
How could I get the static total number of posts which wouldn’t change irrespective of what the user filters? You may be looking for wp_count_posts(): Codex: WP COUNT POSTS Example getting number of all published posts: function get_all_them_posts(){ $count_posts = wp_count_posts(); $published_posts = $count_posts->publish; return $published_posts; } In template: <?php echo get_all_them_posts(); ?> For Custom … Read more
You have to slightly modify your query on your above code as: $postsForSitemap = get_posts( array( ‘numberposts’ => -1, ‘orderby’ => ‘rand’, ‘post_type’ => array( ‘page’ ), ‘post_parent’ => 0, ‘order’ => ‘DESC’ ) ); if you want all page without parent as you have used to get parent pages only. It will generate a … Read more
If I understand your scenario, your events are in the right order but your semesters are not. If you change line 4 $terms = get_terms(‘semesters’); to $terms = get_terms(‘semesters’, array( ‘orderby’ => ‘slug’ ) ); that should put the semesters in the order you’re looking for. ‘order’ defaults to ASC, which is what you need … Read more
I hope this will help you. $args = array( ‘post_type’ => ‘your custom post type here’, ‘posts_per_page’ => 5, ‘category’ => ”, ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); } // end while } // end if wp_reset_query();
I would suggest trying not to over-complicate the logic. You have the general thought process correct in your question. Assuming everything above works when you just add the meta_query logic to the query directly and run it, then your code should try to follow that same thought pattern. You’re accessing the globals – so list … Read more
I’ve found an answer by myself.. (sample code) $args_array = array($post_type); $term_slugs = array(‘foto’, ‘video’); // create a string like ‘%s, %s’ ecc $placeholders = implode(‘, ‘, array_fill(0, count($term_slugs), “%s”)); $term_query = “t.slug IN ($placeholders) “; $args_array = array_merge($args_array, $term_slugs); $ids = $wpdb->get_results($wpdb->prepare(” SELECT m.meta_value FROM ” . $wpdb->prefix . “posts p INNER JOIN ” … Read more
The problem here is that this query has pagination by default, and what you’re asking for is not scalable. For example, this query fetches 5 posts at a time, and displays the 6th page of users: $user_query = new WP_User_Query( array( ‘number’ => 5, ‘offset’ => 25 ) ); You can pass -1 to fetch … Read more
This will help to get the category post on tag archive page. Let me know. <?php $current_tag = single_tag_title( $prefix = ”, $display = false ); $categories = get_categories( array(‘hide_empty’ => TRUE) ); foreach($categories as $category) { ?> <?php $args=array( ‘posts_per_page’ => -1, ‘tag’ => $current_tag, ‘cat’ => $category->term_id, ); $the_query = new WP_Query( $args … Read more
I’m not sure why the first page works but the second doesn’t, though this may be a hint toward the problem. Toward the bottom of the category template page you have the following: if (function_exists(custom_pagination)) { custom_pagination($custom_query->max_num_pages,””,$paged); } If you review the above, there is a variable called $custom_query. This looks like it’s a WordPress … Read more