function wpb_most_commented_posts() {
// start output buffering
ob_start();
?>
<ul class="most-commented">
<?php
// Run WP_Query
// change posts_per_page value to limit the number of posts
$query = new WP_Query('orderby=comment_count&posts_per_page=200');
//begin loop
while ($query->have_posts()) : $query->the_post(); ?>
<a class="list-group-item" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" style="
padding-right: 28px;
"><?php the_title(); ?><span class="label label-default" style="
float: right;
position: absolute;
right: 10px;
top: 12px;
float: right;
">
<?php comments_number( '0', '1', '%' ); ?></span></a>
<?php endwhile;
// end loop
?>
</ul>
<?php
// Turn off output buffering
$output = ob_get_clean();
//Return output
return $output;
}
// Create shortcode
add_shortcode('wpb_most_commented', 'wpb_most_commented_posts');
//Enable shortcode execution in text widgets
add_filter('widget_text', 'do_shortcode');Ama ben sadece bugün en çok yorum alan konuları listelemek istiyorum yardım eder misiniz?
Nasıl bugün en çok yorum yapılan konuları listelerim
2
●235
- 10-05-2017, 03:14:15aşagıdaki kod tum zaman en fazla yorum yapılan konuları listeliyor
- 10-05-2017, 09:10:26Kodları denemedim ama çalışması lazımous_york adlı üyeden alıntı: mesajı görüntüle
<?php function wpb_most_commented_posts() { // start output buffering ob_start(); ?> <ul class="most-commented"> <?php // Run WP_Query // change posts_per_page value to limit the number of posts $args = array( 'date_query' => array( //set date ranges with strings! 'after' => 'today', //Örnek 1 hafta öncesi için: "1 week ago" yazacaksın 'before' => 'today', //allow exact matches to be returned 'inclusive' => true, ), 'orderby' => 'comment_count', 'order' => 'DESC', 'posts_per_page' => '200', 'paged' => '1', ); $query = new WP_Query($args); //begin loop while ($query->have_posts()) : $query->the_post(); ?> <a class="list-group-item" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" style=" padding-right: 28px;"> <?php the_title(); ?> <span class="label label-default" style=" float: right; position: absolute; right: 10px; top: 12px; float: right; "> <?php comments_number( '0', '1', '%' ); ?></span></a> <?php endwhile; // end loop ?> </ul> <?php // Turn off output buffering $output = ob_get_clean(); //Return output return $output; } // Create shortcode add_shortcode('wpb_most_commented', 'wpb_most_commented_posts'); //Enable shortcode execution in text widgets add_filter('widget_text', 'do_shortcode'); - 11-05-2017, 01:15:41aTKn94 adlı üyeden alıntı: mesajı görüntüle
Teşekkür ediyorum öncelikle bu kodda kullanışlı ama ben listenin son gun yapılan yorum sayısına göre listelenmesini istiyorum. burada son gun yazılan yazıları yorum sayısına göre listeliyor.