Is there any way of only retrieving posts with one or more thumbs up (GD star rating plugin)?
gdsr_ftvmin=1 is probably the query parameter you need
gdsr_ftvmin=1 is probably the query parameter you need
When should you use WP_Query vs query_posts() vs get_posts()?
you don’t need if/else on the counter, just check if $count == 3 or 5 to inject a sticky post, insert a regular post in every iteration of the loop, and increment the counter at the bottom.
Have a look at the category parameters of WP_Query
you really shouldn’t use query_posts() for anything other then the main query of the page. Instead you should use wp_query() or get_posts() , also since you return a value before running wp_reset_query() then its never actually being reset. so change your shortcode to this: function casestudy_shortcode($atts){ extract(shortcode_atts(array( ‘type’ => ‘case_studies’, ‘limit’ => ‘1’, ‘case’ => … Read more
Here’s one way of doing it: <?php $courses = get_posts( array( ‘post_type’ => ‘courses’, ‘posts_per_page’ => -1 ) ); if ( $courses ) { print “\n” . ‘<div style=”background:pink”>’; foreach ( $courses as $course_count => $post ) { setup_postdata( $post ); the_title( “\n”, ‘<br>’ ); if ( 5 == $course_count ) { print “\n” . … Read more
Think I’ve figured it out. Here’s the code I used courtesy of this thread on the WP Support Forum. Just replace ()<?php the_author_posts_link(); ?>() with whatever excerpt code you want to use. And Voila! <?php //list 5 latest authors $authors = array(); $count = 0; $args=array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, … Read more
If you have the category ID you can use the category__in parameter eg: <?php $custom_posts->query(array(‘category__in’ =>array(1,2,3))); ?>
Code you are after: <?php $wp_user_search = new WP_User_Query( array( ‘role’ => ‘administrator’ ) ); $admins = $wp_user_search->get_results(); $admin_ids = array(); foreach($admins as $admin) { $admin_ids[] = $admin->ID; } $args = implode(‘,’, $admin_ids); query_posts(“author=$args”); ?>
get_posts may be easier for you to use: $args = array( ‘numberposts’ => 5, ‘category’ => ‘3’ ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <div <?php post_class(); ?> id=”post-<?php the_ID(); ?>” style=”padding-bottom:5px;”> <h2><a href=”https://wordpress.stackexchange.com/questions/22878/<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></h2> <div class=”post_meta”><?php twentyten_posted_on(); … Read more