Get page by template?

The page template’s filename is stored as a post meta with key ‘_wp_page_template’, so basically you can use get_post_meta($post_id, ‘_wp_page_template’, true); to get the template filename for the page with ID $post_id. You can also do the reverse (i.e. getting id from page template filename) using Custom Field Parameters in WP_Query or other wordpress functions. … Read more

How to display a listing template of a certain taxonomy?

What you want to do is impossible without a page.php type of template. There is no template hierarchy that support what you want to achieve. It works exactly the same with categories. taxonomy-categorycourses.php will not display a list of categorycourses, so would category-categorycourses.php if categorycourses was a normal category. If you click on categorycourses, you … Read more

Templates for Custom Post Types and Custom Taxonomies

You have totally missed the naming convention when coming to the taxonomy archive pages, and most probably the same goes for your archive pages for your custom post types Here is how your taxonomy archive pages should look like taxonomy-{taxonomy}-{term}.php – If the taxonomy were sometax, and taxonomy’s term were someterm WordPress would look for … Read more

The Operator “NOT IN” Does Not Work In tax_query

I suspect you need an array for the terms – although I’m not sure why it would work with “IN” and not with “NOT IN”… But I’d try this: function menta_pre_get_posts( $query ) { if ( !is_admin() && $query->is_search() && $query->is_main_query() ) { $term = get_term_by(‘slug’, get_query_var(‘s’), ‘product_tag’); if ( $term && !is_wp_error( $term ) … Read more

Is there a way to use regular categories with custom post types?

No problem, the categories and tags are also registered as taxonomies that you can pass to the taxonomies argument when you call register_post_type(). Categories are category and tags are post_tag. You can also do this later with register_taxonomy_for_object_type(): add_action( ‘init’, ‘wpse6098_init’, 100 ); // 100 so the post type has been registered function wpse6098_init() { … Read more

Ordering Posts List By Taxonomy Terms?

WordPress core (as expressed by involved people on multiple occasions) strongly discourages sort by terms. It sees terms as exclusively grouping mechanism, with no ordering capabilities implied. So in your specific case WP would understand that there are different directors, that there are groups of shows done by those directors, but won’t at all understand … Read more