Query & Order posts by custom fields

You need to use the meta_query parameter of the WP_Class when running a query. Something like this should point you in the right direction. $data = date(“Y-m-d”); $args = array( ‘post_type’ => ‘jogos’, ‘meta_query’ => array( array( ‘key’ => ‘data_de_lancamento’, ‘value’ => $data, ‘compare’ => ‘<=’ ) ), ‘meta_key’ => ‘views’, ‘orderby’ => ‘meta_value’, ‘order’ … Read more

How to use has_archive but disable feed per post type?

I ran into this issue today. I don’t know if it’s the best way, but here’s how I solved it (with has_archive still set to true, of course): // First we remove WP default feed actions // If we stop here, feeds would be disabled altogether remove_action(‘do_feed_rdf’, ‘do_feed_rdf’, 10, 1); remove_action(‘do_feed_rss’, ‘do_feed_rss’, 10, 1); remove_action(‘do_feed_rss2’, … Read more

List custom taxonomy specific to one custom post type

Here’s an example that will list all the mobile_review posts that have the term htc_desire_hd in the taxonomy mobile_phone : $tax_query = array( ‘relation’ => ‘AND’ ); $tax_query[] = array( ‘taxonomy’ => ‘mobile_phone’, ‘terms’ => array(‘htc_desire_hd’), ‘field’ => ‘slug’ ); $args = array( ‘post_type’ => ‘mobile_review’, ‘tax_query’ => $tax_query ); $custom_loop = new WP_Query( $args … Read more

Getting template_include to work when allow_url_include is off?

Wouldn’t ya know – 10 minutes or less since I asked my question and I’ve discovered the answer. I was attempting to define MY_PLUGIN_TEMPLATES using using plugins_dir_url(), now it looks like this and is working: define( ‘MY_PLUGIN_TEMPLATES’, dirname( __FILE__ ) . ‘/templates’ ); Thanks to mfields for the suggestion of dirname instead of WP_PLUGIN_DIR.