template_redirect for single posts w/ custom fields

The problem with your code is that you’re checking is_single() when your plugin is first loaded, before the global query has run, so is_single() still returns false. You should move the is_single() check within your my_template function: function my_template() { if(is_single() && have_posts() && ‘Custom’ == get_post_meta(get_the_ID(), ‘Design’)) { include(PLUGINDIR . ‘/supersqueeze/all.php’); exit; } } … Read more

WP_query : meta_key with custom rule for specific value

A meta_query is an array of arrays. Look at the examples in the the Codex. $args = array( ‘post_type’ => ‘my_custom_post_type’, ‘meta_key’ => ‘age’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘age’, ‘value’ => array(3, 4), ‘compare’ => ‘IN’, ) ) ); $query = new WP_Query($args); What you have is … Read more

Using posts and postmeta table to store custom Address Book Plugin data

Using posts & postmeta: There is nothing wrong in using posts and postmeta table for custom database requirements. In WordPress, although posts & postmeta table was originally there to create blog posts, later it evolved to cover many different sorts of database requirements. Using Custom Post Types, Post Meta & Custom Taxonomies, you can satisfy … Read more