Second loop pagination changes URL, not content
According with the Wodrdpress Codex: Pagination on static front page uses the page query variable, not the paged variable. See the WP_Query for details.
According with the Wodrdpress Codex: Pagination on static front page uses the page query variable, not the paged variable. See the WP_Query for details.
The “main” query on the page is saved to a global called $wp_query. That global determines a great deal about the page, including both content and which template is used to display that content. Using $wp_query overwrites that main query and can cause some very basic things to fail but get_the_category() is probably not one … Read more
If you’re using the WP-PageNavi plugin, there are several FAQs on using it with a secondary query loop: http://wordpress.org/plugins/wp-pagenavi/faq/ this code is from one of the pages linked from that FAQ: $my_query = new WP_Query( array( ‘tag’ => ‘foo’, ‘paged’ => get_query_var(‘paged’) ) ); while ( $my_query->have_posts() ) : $my_query->the_post(); the_title(); // more stuff here … Read more
Not the best solution 😛 but this could help you: select distinct(p.ID) from wp_posts p, wp_term_relationships r, wp_term_taxonomy tt, wp_terms t WHERE p.post_author in (1, 2, 3) and r.object_id = p.ID and tt.term_taxonomy_id = r.term_taxonomy_id and tt.taxonomy = ‘category’ and tt.term_id = t.term_id and t.term_id in (1, 2, 3);
To any one else facing this issue…. I assume your using WP Engine. I only say this because it turns out WP Engine turns off the rand parameter by default. Go to your wp engine dashboard settings, scroll down and enable the random functionality. What a pain.
The obvious first step would be to use get_col instead of get_result. You will get an array returned straightaway so you could skip your foreach and go straight to: $args = array( ‘author__in’ => $following_users_ids, ‘posts_per_page’ => 12, ‘paged’ => $paged, ); Behind the scenes, get_col does much what you are doing but you are … Read more
I see two problems here. One is that the explode() doesn’t actually specify the correct split string, which is ‘, ‘, WITH a space. What is written in the sample: ‘post_type’ => explode( ‘,’, $posttype ), What is written in the example shortcode: [myquery posttype=”cpt_press, cpt_two, cpt_three, cpt_etc”] Note that there is a comma AND … Read more
Try this function cat_loop ($key){ $fashion_cat = array( ‘category_name’ => $key, ‘posts_per_page’ => 4, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post__not_in’ => $already_posted, ‘category__not_in’ => $private_categories ); // Add the loop. } cat_loop (‘fashion’); cat_loop (‘beauty’); cat_loop (‘lifestyle’); put the loop in function which has variable for the category_name … Read more
Remove your filter and add orderby’=>’post__in’. That sort order in not automatic when you supply IDs. $wp_query = new WP_Query( array( ‘post__in’ => $arrayPostsIds, ‘ignore_sticky_posts’ => true, ‘date_query’ => $date_query , ‘orderby’ => ‘post__in’, ) );
WP_Query itself can’t do that logic internally but you can easily create the query dynamically. $args = array( ‘meta_key’ => ‘name’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ‘posts_per_page’ => ‘-1’ ); if ($post->ID == 1) { $args[‘category_name’] = ‘first’; } elseif ($post->ID == 2) { $args[‘category_name’] = ‘second’; } $custom_loop = new WP_Query($args);