Sort search results by post type

I found the key: SQL CASE Expression function order_search_by_posttype($orderby){ if (!is_admin() && is_search()) : global $wpdb; $orderby = ” CASE WHEN {$wpdb->prefix}posts.post_type=”artist” THEN ‘1’ WHEN {$wpdb->prefix}posts.post_type=”post” THEN ‘2’ WHEN {$wpdb->prefix}posts.post_type=”artwork” THEN ‘3’ WHEN {$wpdb->prefix}posts.post_type=”publication” THEN ‘4’ ELSE {$wpdb->prefix}posts.post_type END ASC, {$wpdb->prefix}posts.post_title ASC”; endif; return $orderby; } add_filter(‘posts_orderby’, ‘order_search_by_posttype’);

How to create a custom template for a custom taxonomy?

Templates See the Template Hiearchy for a more detailed break down of how WordPress chooses the template. For a taxonomy term slug (‘monitors’ your example) in the taxonomy taxonomy (e.g. ‘products’) WordPress will try to use the following templates (in this order) taxonomy-{taxonomy}-{slug}.php taxonomy-{taxonomy}.php taxonomy.php archive.php index.php For your ‘monitors’ taxonomy term page, WordPress will … Read more

Create a ‘single’ page for a Custom Post Type

Use single-{posttype}.php for the single template. Also, if you register your post type with the has_archive argument set to true, then you can use archive-{posttype}.php for your archive template, which will allow you to skip that query that you have there, since the global $wp_query object will already be populated with your custom post type. … Read more

Show Custom Taxonomy Inside Custom Menu

You have some messed up code. I have reformatted your code to code which actually works. The following solution allows you to give your Custom Post Type menu a menu name of what ever you want. Just change the label “menu_name”. POST TYPE // Create the news custom post type register_post_type(‘nwcm_news’, array( ‘labels’ => array( … Read more

Inconsistent temporary 404s on whole install | PHP error with post-template.php

There are two types of 404 errors: WordPress-generated, and server-generated. In some server environments, 404s could be inaccurately displayed by the server in cases of CPU overload or due to certain instances of misconfiguration, etc. Usually server-generated 404 errors will say something like “Nginx” or “Apache” at the bottom of the page (depends on server … Read more