New rewrite rules for custom taxonomy and reuse default

Note that the url-rewriting doesn’t directly determine the template used. A pretty url is interpreted as a query and then that query determines what template is used based on the template hierarchy. So only need one rule: example.com/localdeals/myterm => example.com/?location=myterm WordPress will look for the template taxonomy-location-myterm.php and use that (if it exists) or otherwise … Read more

exclude posts from a custom category

If you want to exclude posts from a particular category then you could try putting this in your functions.php function exclude_posts_from_category( $query ) { $catname = “Put you category name here”; if ( $query->is_category() && ( $catname == $query->query_vars[‘category_name’] ) ) { $query->query_vars[‘post__not_in ‘] = array( 1, 2, 3 ); } } add_action( ‘pre_get_posts’, ‘exclude_posts_from_category’ … Read more

Changing checkbox array from single to multiple select

After days and days of frustration, I’m proudly answering my own question. The original code was not displaying multiple checkboxes because I was using the conditional !strcmp( $term->slug, $selected[0]->slug ) to render my “checked” options. Somehow it only returned 1 “checked” value at best. The correct conditional simply gets the value of the selected option, … Read more

Altering term_id and name via $wpdb class

You can do it easily. Your query should be: $querystr = “SELECT `term_id` AS `id`, `name` AS `value`, `slug`, `term_group` FROM {$wpdb->terms} WHERE lower($wpdb->terms.name) like ‘%$s%'”; See, here i’ve mentioned the name of the fields needed. For any other fields, you need to explicitly mention the field names.

Tags and Taxonomy links not working for Custom Post Types

I had to modify queries before they run. So the best practice was to add the following code to function.php: if (!function_exists(‘my_theme_filter’)) { function my_theme_filter( $query ){ if ( $query->is_main_query() ) if ( $query->get( ‘tag’ ) OR is_search() ) $query->set( ‘post_type’, array( ‘artprim_item’ ) ); //echo ‘<pre>’; print_r($query); echo ‘</pre>’; return $query; }} add_filter( ‘pre_get_posts’, … Read more