WP_QUERY wrong ammount of posts

But all of them get obtained from the database. The problem is that you’re ignoring half of them. Or rather merging two of them and displaying as one. Let’s take a look at your code: while ( $query->have_posts() ) { $query->the_post(); // <- here you call the_post() first time $output.='<div class=”entry filter_product”>’; // and in … Read more

AJAX Breaking Offset Argument In WP Query

So I’m guessing this is a follow-up to this question. And based on my answer there, you can use/add the offset parameter like so: In category.php, just set the preferred offset: $the_query = new WP_Query( array( ‘category__in’ => array( $cat_id ), ‘post_type’ => ‘post’, ‘posts_per_page’ => 5, ‘paged’ => $current_page, ‘offset’ => 1, // set … Read more

use loop to return blog details

You need to re-arrange your code. <?php $post_id = 20; while($post_id <= 25) { $queried_post = get_post($post_id); $author_id = $queried_post->post_author; echo get_the_author_meta(‘display_name’, $author_id); $post_id++; } ?> Within while loop above you have $queried_post which is an object of class WP_Post. Member Variables of WP_Post can be used to display data about each post. I hope … Read more

Include future posts in tags and in search

To achieve the intended result you will have to modify the query by adding the future value to the post_status parameter via the pre_get_posts filter hook. add_action( ‘pre_get_posts’, ‘se338152_future_post_tag_and_search’ ); function se338152_future_post_tag_and_search( $query ) { // apply changes only for search and tag archive if ( ! ( $query->is_main_query() && (is_tag() || is_search()) ) ) … Read more

Pagination broken after using 2 loops to show content

So here is my attempt at it…though I don’t really have a good place to test it on my end, but I think it should work. (Fingers Crossed) <?php // First Page of Pagination – https://codex.wordpress.org/Function_Reference/is_paged if(!is_paged()){ $first_page = true; $query_args = array( ‘posts_per_page’ => ’11’, ); } else { $query_args = array( ‘posts_per_page’ => … Read more

How to get user ID’s from multiple usernames?

Your call to get_user_by() has a small hiccup in it. It needs to be login rather than user_login // Search these Usernames $usernames = array(‘user1’, ‘user2’); // Fetch the User IDs $prof_ids = array(); foreach ($usernames as $prof_id) { $user = get_user_by(‘login’, $prof_id); $prof_ids[] = $user->ID; } // WP_User_Query arguments $args = array( ‘include’ => … Read more

Category tags with comma’s

In this line: $cats .= $category->name . ‘, ‘; You append a name of category to variable called $cats. But you never reset this variable. So every post appends its categories to the same variable. So here’s how to fix this: <?php $categories = get_the_terms($custom_args->ID, ‘veranstaltungen-category’); $cats=””; // set empty string as value foreach ($categories … Read more

WP ForLoop to compare meta information of posts to determine what post to display

Your query should be something like this: $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 1, ‘meta_key’ => ‘<ACF FIELD KEY HERE>’, ‘meta_value’ => date( “Ymd” ), ‘meta_compare’ => ‘>’, ‘meta_query’ => array( ‘key’ => ‘<ACF FIELD KEY HERE>’, ‘value’ => date( “Ymd” ), ‘compare’ => ‘>’ ), ‘orderby’ => ‘meta_value_datetime’, ‘order’ => ‘ASC’, ); … Read more