Pagination not working Search posts
Pagination not working Search posts
Pagination not working Search posts
Try something like this: $sotmArticle_query = new WP_Query( array( ‘post_type’ => ‘news’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘postCat’, ‘field’ => ‘slug’, ‘terms’ => ‘sotm’ ) ), ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 1 ) ); if($sotmArticle_query->have_posts()){ while($sotmArticle_query->have_posts()){ $sotmArticle_query->the_post(); ?>
Straight from the codex value (string|array) – Custom field value. It can be an array only when compare is ‘IN’, ‘NOT IN’, ‘BETWEEN’, or ‘NOT BETWEEN’. SOLUTION Change compare’ => ‘!=’ to compare’ => ‘NOT IN’
You don’t need the type variable and other bits of custom search query code, or custom functions like the other answers. In your searchbox, instead of submitting the form to / submit it to /my_post_type/ instead! WordPress will handle all the rest for you automagically, with no effort involved. What’s more this means all the … Read more
I tested the query and it does work so the only thing I can spot that is misleading but not right is directly after you while() statement you have the_post(). This doesn’t work in secondary queries, it should look like: <?php if( $subpages->have_posts() ) : ?> <?php while( $subpages->have_posts() ) : $subpages->the_post(); ?> … <?php … Read more
Pagination should be easy. You really just need to add pagination parameters to your query, and next/previous posts links, more or less like in another thread I posted in recently. $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $my_query = new WP_Query( array( ‘showposts’=>10, ‘paged’ => $paged ) ); // run the loop then, // pagination … Read more
No, meta_query does not support these sorts of complex clauses in a sequence. There are a couple of ways to work around this limitation. One is to filter posts_where_paged and modify the SQL manually. I just spent a couple minutes playing with this option, and it’s not very straightforward – you’ll have to write a … Read more
For those looking for an answer: My meta fields id’s in functions.php had a variable @prefix applied before the name. I added that prefix on the template and, voile! Still unsure why my homepage template was working correctly with the wrong meta id’s, but an answer nonetheless.
As you can read in Codex about orderby and the WP_Query, you can use multiple orderby values as well: ‘orderby’ => ‘name meta_value’ simply by using a space in between. The available orderby values are listed in the Codex page. About your question: By default it should already work with your query. If it doesn’t, … Read more
I like the idea proposed in this comment. Connecting the posts table to the comments table seems like it’d be some super complicated SQL (well all SQL is complicated to me). Instead the link proposes that you add a post meta field to the post to hold the date of the most recent comment. add_action(‘comment_unapproved_to_approved’, … Read more