John P Bloch bu müthiş kodu bir göz atın. Bu kod olduğunu:
Bu, varsayılan olarak görüntülenir olacak kaç mesaj bakar. O 20 daha az ise, bu farkı kapmak (bu durumda, 10 Mesajları kapmak gerekir) ve mevcut sorguya ekler. Sonra o 20 iletisinin altında hala görmek için kendisi ile recurses. Eğer öyleyse, en az 20 mesaj vurur kadar, o çalışmaya devam eder.
function my_awesome_post_booster(){
if(!is_home())
return;
global $wp_query;
if( $wp_query->post_count < 20 ){
$how_many = 20 - $wp_query->post_count;
$newposts = get_posts('numberposts='.$how_many);
$wp_query->posts = array_merge( $wp_query->posts, $newposts );
$wp_query->post_count += count($newposts);
my_awesome_post_booster();
}
}
add_action('template_redirect', 'my_awesome_post_booster');
Sorun kendisi düşünce, bu devam etmez recurses değildir, değildir.
I 20 ulaşıncaya kadar kod onları 4 kez tekrarlamak gerekir, 5. mesaj var. Ama öyle değil diyelim.
Herhangi bir fikir neden? Ty
P.S. Burada benim fikrim php koymak nasıl tho emin değil, olduğunu.
Ben 5 mesaj var diyelim.
$wp_query->post_count will be 5
$how_many = 20 - $wp_query->post_count; will be 15
$newposts = get_posts('numberposts='.$how_many); - will try to get 15 posts, but it can't, cause the blog only has 5!
The scrip thinks he pulled 15, even tho he didn't.
Fikir 5'tir mesajların gerçek sayıya $ how_many bölmek, ancak bu gibi .... bir çift sayı elde etmektir:
$how_many = 20 - $wp_query->post_count; will be 15
divide $how_many with $wp_query->post_count;
make sure it's an even number, lets say 3,33, makes it 3...
$newposts = get_posts('numberposts='.$that_numer);
U ne düşünüyorsunuz? :) Ben php içine koyabilir miyim?