How to sort a loop after most viewed

Having taken a quick look at the wp-postviews documentation, it seems you can change query_posts( ‘posts_per_page=5’ ); to query_posts( ‘posts_per_page=5&v_sortby=views&v_orderby=desc’ );, but I haven’t tested that. Give it a shot and see how it turns out. A cautionary note on doing this: What often happens when you sort by views is that the first page … Read more

How to sort by most watched in X days/months

Not sure exactly what you mean by “x days or months”, but I’m assuming you want to set a time interval for the posts that you are querying. I would recommend that you take a look at the “Time Parameters” section in the Codex article on WP_Query. It does an excellent job explain how to … Read more

the_post(); prints out style text into my HTML?

You can view the actions and filters being used in your plugins and themes. I’m assuming something is hooked into the_post action somewhere. Dumping the following globals give you a peek behind the curtain here. global $wp_actions, $wp_filters; Once you identify the source, you either queue up the CSS properly in the HEAD, or remove … Read more

Pagination in author, category, archive and tags pages does not work

This looks like a simular issue to this one with wp-pageNavi: http://scribu.net/wordpress/wp-pagenavi/right-way-to-use-query_posts.html. Taxonomies and archives should use ‘page’, not ‘paged’ so use that in the urls to begin with. Then, to ensure your pagination script works in all locations you can change the way you get your $paged variable. Something like this should do it: … Read more

How do I list a custom field and custom taxonomies for each result in a loop?

You can get custom field values with get_post_meta. Like so… <?php $wp_query = new WP_Query(); $wp_query->query(‘post_type=customtype&showposts=10′.’&paged=’.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); the_title(); // <- works if( $some_meta = get_post_meta( get_the_ID(), ‘the_meta_key_you_want’, true ) { // you could put other formatting here. echo $some_meta; } endwhile; You’ll need to change the_meta_key_you_want in the call to get_post_meta, of … Read more

Add class to every other posts using get_posts

A simple solution would be to add an alternating class to every other post in the list. In particular, (in your style.css) style the list elements <li> in one particular way, and then over-ride that style for list elements of a particular class <li class=”my-alternate-class”>. The class my-alternate-cass will applied to every other list element: … Read more