Why have my custom post type searches stopped working after changing URLs / updating WordPress?

It’s possible that, after moving the site, you hadn’t updated WordPress’ understanding of where the site is located. You might want to try adding the following to your wp-config.php file: define(‘WP_SITEURL’, ‘http://www.seriouslyfish.com’); define(‘WP_HOME’, ‘http://www.seriouslyfish.com’); This will override the settings in the database. WordPress uses the location settings to direct rewrite traffic, so this might solve … Read more

Ordering posts by custom taxonomy in admin area

Here is what I do to sort my custom post type by custom taxonomy in the admin. I have a custom post type called plugin_filter and a custom taxonomy assigned to it called filter_group. I add the following filter to my plugin to make the field sortable. add_filter(“manage_edit-plugin_filter_sortable_columns”, ‘plugin_filter_sort’); function plugin_filter_sort($columns) { $custom = array( … Read more

WordPress Custom Post Type is Matching on Partial Slug

Add this code in your active theme’s functions.php file and it should stop WordPress guessing the source of the incomplete slug: function no_redirect_guess_404_permalink( $header ){ global $wp_query; if( is_404() ) unset( $wp_query->query_vars[‘name’] ); return $header; } add_filter( ‘status_header’, ‘no_redirect_guess_404_permalink’ ); Original answer here

How to give a CPT (custom post type) a date based url

Assuming that your event rewrite slug is event and you want your datebased URLs to look like: http://domain.com/event/2011-06-14/ function custom_permalink_for_my_cpt( $rules ) { $custom_rules = array(); // a rewrite rule to add our custom date based urls $custom_rules[‘event/([0-9]{4}-[0-9]{2}-[0-9]{2})/?$’] = ‘index.php?post_type=event&event-date=$matches[1]’; return $custom_rules + $rules; } add_filter( ‘rewrite_rules_array’, ‘custom_permalink_for_my_cpt’ ); // add a query var so … Read more

Taxonomy term in permalink

Take a look at this post How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name Accompanied by: How to change permalink structure for custom post type and it’s taxonomies? and Custom post types, taxonomies, and permalinks It will cover what you are trying to do for /category/subcategory/othersubcategory/posttitle. Edit: I … Read more

Creating custom user roles

Adding a role is very simple. Creating custom capabilities is a little bit more to wrap your head around. When you register your custom post type, you define your capabilities for it. Essentially it is an array of “what do you want to count as this?”. My example below will clarify this statement. $caps = … Read more

WP_Query ignores post_type in category view

Have you tried using get_posts() instead? //#get access to post settings global $post; //#set parameters for extra loop $args = array( ‘post_type’ => ‘mycustomtype’, ‘posts_per_page’ => 12, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post_status’ => ‘publish’ ); //#get posts $customPosts = get_posts($args); //#loop through them foreach($customPosts as $post) { //#set all the loop functions to … Read more

Hide custom post type field from author?

The easiest way to do that would be to check the capabilities with current_user_can before displaying the field. For instance, the administrator role has the capability manage_options which your newly created users won’t have. So you can do something like this: <?php // wherever your fields are… if(current_user_can(‘manage_options’)) { // display your fields here. } … Read more