Get post and all posts after it by ID?

I think you’re on the right path with posts_where, something like this should work: <?php function my_filter_where($where){ global $my_current_id; $where .= ” AND ID >= “.$my_current_id; return $where; } // random number I chose for sake of example $my_current_id = 30; add_filter(‘posts_where’, ‘my_filter_where’); $my_posts = new WP_Query(“posts_per_page=5&orderby=ID&order=ASC”); remove_filter(‘posts_where’, ‘my_filter_where’);

Using ajax with paging and a custom sub-query

Two options- load a page fragment using jQuery’s load method (see Loading Page Fragments), or create your own ajax function to load posts and return it in whatever markup you wish: add_action(‘wp_ajax_my_ajax_get_posts’, ‘my_ajax_callback’); add_action(‘wp_ajax_nopriv_my_ajax_get_posts’, ‘my_ajax_callback’); function my_ajax_callback() { $args = $_POST[‘myargs’]; $collected_child_posts = new WP_Query($args); echo ‘some stuff’; die(); } pass the admin-ajax url to … Read more

Authors List page : how to exclude posts from certain category

Ahh friend, you don’t need such a hard way! This should do… <?php $curauth = get_userdata($row->ID); $user_link = get_author_posts_url($curauth->ID); $posts = get_posts(array( ‘author’ => $curauth->ID, ‘cat’ => 60, //for single category, 60 ‘cat’ => -60, //for excluding this category ‘posts_per_page’ => -1, ) ); $post_count = count($posts); ?> Remove the commented line as per your … Read more

WordPress pagination with get_posts?

This is all sorts of wrong. First don’t use start_wp(); I think that was depreciated 4 years ago. Second your loop is messy, query_posts is for altering the main loop, aka not get_posts. So just write it normally using get_posts or WP Query. $args = array( ‘numberposts’ => 1, ‘offset’=> 0, ‘category_name’ => ‘carrs, dominicks, … Read more

Search breaks when querying main loop for category

For your second example, I think you’re initiating your Loop incorrectly. You’re declaring $query, which hasn’t been globalized? // Search is working, querying is not global $query_string; // required $posts = query_posts($query_string.’&posts_per_page=3&cat=$catid’); while ( $query->have_posts() ) : $query->the_post(); Try omitting $query from your Loop initiation? // Search is working, querying is not global $query_string; // … Read more

Possible to display posts containing a short code ?

Taxonomy Query Always use get_posts() for sidequeries. query_posts() is only for the Main query and new WP_Query() should be used for the second queries only. Read more here. You can query posts by a taxonomy (category, term, etc.): $cat_posts = new WP_Query( array( ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘movie_janner’, ‘field’ => … Read more