WP_Query multiple post results

Your loop is wrong, you should not use to foreach inside the while, simply add the classic the_post () using the variable of your loop in this case $ loop for example <?php $args = array( ‘post_type’ => ‘product’, ‘stock’ => 1, ‘posts_per_page’ => 9, ‘product_cat’ => $pagename, ); $loop = new WP_Query( $args ); … Read more

Problem with custom loop and wp_list_pluck [closed]

Problem solved! You need to change this part of code before 3rd query… it will merge you previous queries and exclude posts from them: $first_grid_posts_ids = wp_list_pluck( $first_grid_query->posts, ‘ID’ ); $second_grid_posts_ids = wp_list_pluck( $second_grid_query->posts, ‘ID’ ); $allTheIDs = array_merge( $first_grid_posts_ids , $second_grid_posts_ids ); $third_grid_query = new WP_Query( array( ‘posts_per_page’=>4, ‘post_type’ => ‘post’, ‘cat’ => get_query_var(‘cat’), … Read more

Problem with calling custom function in a foreach loop

First you need to pass the post_id to this function to use the post_id inside the get_the_category($post_id) function incomplete_cat_list($post_id = ”) { global $post; $post_id = ($post_id) ? $post_id : $post->ID; $first_time = 1; $categories = get_the_category($post_id); foreach($categories as $category) { if ($category->cat_name != ‘Category Name’) { if ($first_time == 1) { echo ‘<a class=”cat-list” … Read more

Genesis Framework: How to exclude a specific author from archive custom loop

You can do it with the pre_get_posts hook. In WP_Query there is an author parameter : https://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters pre_get_posts hook : https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts function wpse_288986_remove_post_from_author($query) { // We have to check if we are in front and if the query is the main query if(!is_admin() && $query->is_main_query() && is_archive()) { $query->set(‘author’, -2); // Where 2 is your … Read more

Trying to add_action in a loop

As Milo hints at in their comment, custom post types can only be registered on the init hook. Therefore, if you are trying to get all the public but not builtin post types before init, then get_post_types() will return an empty array. (You can use get_post_types() to get the builtin post types before init.) What … Read more

Loop to display ONLY custom taxonomy parent information [closed]

I believe this has already been answered perfectly in How can I get only parent terms?. The solution is to set ‘parent’ => 0 when querying terms with get_terms() or WP_Term_Query. The example from that question looked like this: $myterms = get_terms( array( ‘taxonomy’ => ‘taxonomy_name’, ‘parent’ => 0 ) ); You can easily loop … Read more