Problem with custom post type search

This is not related only to your custom post_types search. WordPress has a problem on empty search on itself. I use this simple code snippet as workaround: add_filter( ‘request’, ‘my_request_filter’ ); function my_request_filter( $query_vars ) { if( isset( $_GET[‘s’] ) && empty( $_GET[‘s’] ) ) { $query_vars[‘s’] = ” “; } return $query_vars; } You … Read more

Canonicalization + Custom Post Types not working as expected

Think ive solved it and can’t believe what it was! On my rewrite rule I had: add_rewrite_rule( ‘custom-post-type/([0-9]+)/([^/]*)/?$’, ‘index.php?post_type=customposttype&p=$matches[1]’, ‘top’ ); Adding in and passing the post_name for the custom post type got it to start redirecting. add_rewrite_rule( ‘custom-post-type/([0-9]+)/([^/]*)/?$’, ‘index.php?post_type=customposttype&p=$matches[1]&customposttype=$matches[2]’, ‘top’ ); Anycase for now its late and it seems to have started working 🙂 … Read more

Page that ‘subscribes’ to multiple categories

Enable the category taxonomy for your custom post type, or enable it for the default page post type: function wpa_cats_for_pages(){ register_taxonomy_for_object_type( ‘category’, ‘page’ ); } add_action( ‘init’, ‘wpa_cats_for_pages’ ); Then within your page template, get the category IDs assigned to the client page and create a new query which passes those IDs: // get IDs … Read more