showposts VS posts_per_page. showposts works perfect but deprecated!


showposts VS posts_per_page. showposts works perfect but deprecated!



I'm unable to substitute posts_per_page with showposts in order to limit the number of posts returned in a list. When I use showposts, the resulting menu list is correctly displayed according to the number of posts I specify in the showposts limiter. However, when I use posts_per_page, the post limiter number appears to be irrelevant. The resulting list shows all posts, exceeding the limiter count.

Examples:

This works perfectly:

$myrecentposts = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat,-$catHidden",'showposts' => $cb2_recent_count)); foreach($myrecentposts as  $idxrecent=>$post) { 

However, when I sub in posts_per_page, this DOES NOT work...

$myrecentposts = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat,-$catHidden",'posts_per_page' => $cb2_recent_count)); foreach($myrecentposts as  $idxrecent=>$post) { 

*I'm only trying to get posts_per_page to work because I understand that showposts has been deprecated.


wordpress extended_valid_elements for script tag?

1:

Plugin Suggestions - Wordpress as a Membership Directory
showposts is deprecated. How to query posts for a custom post type in a custom taxonomy ? in wordpress 3.0However, posts_per_page is for use with query_posts(), or more specifically, WP_Query::query().. Why my wordpress plugin settings shows up for users other than administrator? numberposts is the equivalent argument for receive _posts().. Is there a way to redirect users who are not administrator from WordPress wp-admin? NOTE: I removed my original answer concerning incorrect handling of arguments inside receive _posts().. Custom image upload field in WordPress posts_per_page is not a valid argument for receive _posts() for semantic reasons, since it suggests the idea of pagination, any thing which receive _posts() does not support.. very odd 404 on wp-admin directory For clarity, and on behalf of @RichardM's comment, here's the skinny I originally wrote;. Data Export It's down to how receive _posts() parses the arguments before passing them on to WP_Query.. I've cut it down to the real basics here;.
function receive _posts($args = null) {     $defaults = array('numberposts' => 5);     $r = wp_parse_args($args, $defaults);      if (!empty($r['numberposts']))         $r['posts_per_page'] = $r['numberposts'];      $receive _posts = new WP_Query;     return $receive _posts->query($r); } 
See how numberposts overwrites posts_per_page, not accounting the condition this posts_per_page is being passed?.

2:

There is a bug : http://core.trac.wordpress.org/ticket/15150 it is fixed in 3.1.


67 out of 100 based on 42 user ratings 837 reviews

Wordpress cron problems
most stable / useful way to blog in Magento
Wordpress 3.0 Register/Login Menu Button
Get all posts starting with an alphabet in wordpress
Wordpress - Allow a userclass to save a page as a draft - but not publish w/o admin approval
WordPress 3.0.1 Install on MS IIS v6 Web Server
طه الفشنی - ابتهال بسیار زیبای حب الحسین
اقامه نماز جماعت ظهر به امامت رهبر معظم انقلاب آیت الله امام خامنه ای (حسینیه امام خمینی(ره))
اقامه نماز جماعت مغرب به امامت آیت الله یثربی (کاشان)
اقامه نماز جماعت مغرب به امامت رهبر معظم انقلاب آیت الله امام خامنه ای (حسینیه امام خمینی(ره))
اقامه نماز جماعت به امامت حجت الاسلام و المسلمین حسینی ایازی (حرم مطهر رضوی)
اقامه نماز جماعت ظهر به امامت حجت الاسلام و المسلمین محسن قرائتی (مسجد دانشگاه تهران)
اقامه نماز جماعت ظهر عاشورا به امامت حجت الاسلام و المسلمین حسن زاده (اهواز)
اقامه نماز جماعت ظهر به امامت آیت الله ابوالحسن مهدوی (مسجد امام(ره) اصفهان)
نماز جماعت ظهر به امامت حجت الاسلام سید محمد مهدی دستغیب (حرم مطهر حضرت احمد بن موسی شاهچراغ(ع)-شیراز)
نماز جماعت مغرب به امامت آیت الله سید باقر مصطفوی (حرم مطهر حضرت محمد هلال بن علی(ع)-مشهد اردهال(آران و بیدگل-کاشان))
*