anbimedia
Forum Replies Created
Viewing 3 replies - 1 through 3 (of 3 total)
-
Forum: Plugins
In reply to: [Thumbs Rating] Posts with zero votes are not queriedForum: Plugins
In reply to: [Thumbs Rating] Posts with zero votes are not queriedHi!
My solution has been to put two loops on the page… :O
The second loop excludes all post with _thumbs_rating_up meta_keyFirst, show the post with votes:
<!-- Posts només amb vots --> <?php $args = array ( 'post_type' => 'post', 'post_status' => 'publish', 'cat' => '2', 'pagination' => false, 'posts_per_page' => '100', 'cache_results' => true, 'meta_key' => '_thumbs_rating_up', // or '_thumbs_rating_down' 'orderby' => 'meta_value_num', ); $postslist = get_posts( $args ); foreach ( $postslist as $post ) : setup_postdata( $post ); ?> <div class="post-2016"> <li><a>"><?php the_title(); ?></a></li> <?php if ( has_post_thumbnail() ) { $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); echo '<a href="' . $large_image_url[0] . '" title="' . the_title_attribute( 'echo=0' ) . '">'; echo get_the_post_thumbnail( $post->ID, 'large' ); echo '</a>'; } ?> <?=function_exists('thumbs_rating_getlink') ? thumbs_rating_getlink() : ''?> </div> <?php endforeach; wp_reset_postdata(); ?> <!-- Posts només amb vots END -->And then… show all the post excluding _thumbs_rating_up meta_key:
<!-- Posts sense vots --> <?php $excludeposts = $wpdb->get_col( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_thumbs_rating_up' AND meta_value != '' ORDER BY post_id DESC LIMIT 0, 100" ); $main_query = new WP_Query( array( 'post__not_in' => $excludeposts, 'paged' => $paged, 'cat' => '2', 'posts_per_page' => '100', ) ); while ($main_query->have_posts()) : $main_query->the_post();?> <div <?php post_class(); ?> id="post"> <div class="thumb"><a>"><?php the_post_thumbnail('thumbnail' , 'alt="' . $post->post_title . '"' , $post->ID, array()); ?></a></div> <p class="date"><?php the_time('d/m/Y') ?></p> <h1><a>"><?php the_title(); ?></a></h1> <?=function_exists('thumbs_rating_getlink') ? thumbs_rating_getlink() : ''?> </div> <?php endwhile; ?> <!-- Posts sense vots END -->Perhaps not very elegant, but it works!
AccessPress Anonymous Post Plugin it’s better…
Viewing 3 replies - 1 through 3 (of 3 total)