get_posts array ‘between’ not behaving
As you are looking at post IDs, you should be using meta_value_num instead of meta_value as your key. This will indicate to WP how to handle the comparison.
As you are looking at post IDs, you should be using meta_value_num instead of meta_value as your key. This will indicate to WP how to handle the comparison.
@Milo’s answer worked perfectly (see comment above). if (in_array($post->ID, $do_not_duplicate)) continue; meant that duplicate posts were still being counted in the loop, though not being displayed. To fix, remove this line, and exclude duplicate posts from the query with this argument: ‘post__not_in’ => $do_not_duplicate. Thank you @Milo for your swift and succinct response.
No, it doesn’t work like that because meta_query is for custom fields and tax_query is for taxonomies. But what you could do is run two separate queries to get all of the IDs that qualify, and then use those IDs in a 3rd query with post__in. For example: $cat_query_args = array( ‘posts_per_page’ => -1, ‘cat’ … Read more
Ordering Posts by parent category, name ascending
I think you need to read up a bit on how The Loop works in WordPress: https://codex.wordpress.org/The_Loop And how the WP_Query class: https://codex.wordpress.org/Class_Reference/WP_Query I am assuming your only want 2 loops, at the moment your have 3. On line 19, which stores its posts in a var $query then does nothing. On line 21, which … Read more
If you are making a one-page website, and you are going to use WordPress, create a WordPress “Page”, and put your content in it. Then in the Dashboard > Settings > Reading > Front Page Displays, select “A static page”, and choose the page you created. To create a WordPress “Loop” within a page, you … Read more
If you want max_num_pages, you need to use WP_Query instead of get_posts. You can then use $your_query_object->max_num_pages in your code. offset and paged don’t work together, because both of them ultimately set LIMIT in the MySQL query. offset query parameter will always override paged. If you want to offset the results, you need to do … Read more
Decrement term in for each
I was able to figure it out myself, here is the code: <div id=”fullpage”> <?php //for each category, show 5 posts $cat_args=array( ‘orderby’ => ‘name’, ‘order’ => ‘desc’ ); $categories=get_categories($cat_args); foreach($categories as $category) { $args=array( ‘showposts’ => 5, ‘category__in’ => array($category->term_id), ); $posts=get_posts($args); if ($posts) { echo ‘<section class=”vertical-scrolling” data-anchor=”‘ . $category->name.'”>’; foreach($posts as $post) … Read more
Per @Milo’s comment: probably post_status, which defaults to publish – Milo 53 mins ago So I just set ‘post_status’ => ‘wc_completed’ in my args and I’m good.