Order by meta value, pro first, then free

Before I fire away, just one note, NEVER (my emphasis) make use of query_posts to create custom queries Note: This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query … Read more

Best way to load page content in Fancybox popup?

I have found that the best way to include WordPress pages into a fancybox is to create a new template to use for those pages. For example I have some of my contact forms in a fancy box and the template I use is called custom-page-plain.php and doesn’t call header.php and contains a link to … Read more

WordPress Custom Query

<?php $querystr = ” SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = ‘date_field’ AND wpostmeta.meta_value=”03/11/2010″ AND wposts.post_status=”publish” AND wposts.post_type=”post” ORDER BY wposts.post_date DESC “; $pageposts = $wpdb->get_results($querystr, OBJECT); ?> Then you would access $pageposts as an object

Pagination on archive.php page

I think your issue is that wp_pagenavi() is doing pagination based off of the global $wp_query instance instead instance you created. You should either switch to using query_posts() to replace the global query instead, or use WordPress’ built in paginate_links to output the paging.

Sort X categories by last update and show image

Here’s one solution: global $wpdb; $cat_array = $wpdb->get_results( ” SELECT terms.*, posts.ID as post_ID FROM wp_terms terms JOIN wp_term_taxonomy term_taxonomy ON terms.term_id = term_taxonomy.term_id JOIN wp_term_relationships term_relationships ON ( term_relationships.term_taxonomy_id = term_taxonomy.term_taxonomy_id AND term_taxonomy.taxonomy = ‘category’ ) JOIN wp_posts posts ON ( posts.ID = term_relationships.object_id AND posts.post_type=”post” AND posts.post_status=”publish” ) GROUP BY terms.term_id ORDER BY … Read more