CustomPress--need to set default taxonomy on custom post type

Is there a setting somewhere to make one of the custom taxonomies the "default" taxonomy?

When you publish a custom post without selecting a taxonomy at all, one should be assigned to the post as a default, as it is in the default WordPress post type. It's not behaving this way in my installation of the plugin. Did I miss a setting somewhere?

Thanks!

  • Raevenne

    Hi Vaughan,

    Not sure I understand what you're getting at. The box to "Support Regular Taxonomies"--doesn't that only apply if you don't make custom taxonomies for the post type?

    I've set up the custom taxonomies for the post type, and they are showing up in a meta box on the custom post page. If I don't check any of the taxonomies, the post is published with no taxonomies assigned. There should be a way to assign a default custom taxonomy to all posts of that post type, the same way that all default posts default to the "Uncategorized" category on a fresh WordPress install.

  • Raevenne

    Hi Arnold,

    Obviously I'm not explaining this very well so let's start at the beginning, and forget about CustomPress for a minute.

    In Wordpress, there is a "default" category called "Uncategorized" that is there upon installing the program to your server. Now, most folks will go and edit that category and call it something else, but regardless, that's still the default category that all posts will be a part of, unless you select a different category when you publish the post or edit the post. When you publish a post, if you don't select a category at all, that default category is automatically selected for you, and the Categories box will look like the first attached screenshot after publishing the post.

    Now, on to CustomPress. Yes, I've set up the custom hierarchical taxonomy to be associated with the custom post type. For lack of a better taxonomy label for my purposes, I used show_category as the Taxonomy and Category as the Name. However, when I publish a custom post and do not select one of the terms in my Category box, no default term is assigned to the post at all and the post is left without a taxonomy term as shown in the second screenshot attached here.

    There should be a way to select one of the taxonomy terms created as part of the custom taxonomy as the default term so that posts that are published without a taxonomy term selected are automatically assigned to one.

    I hope my question is a bit more clear now.

  • Arnold

    OK I understand what you want. The problem is that Wordpress filters out all post types except "post" when assigning a default category.

    // Make sure we set a valid category.
    if ( empty($post_category) || 0 == count($post_category) || !is_array($post_category) ) {
      // 'post' requires at least one category.
      if ( 'post' == $post_type && 'auto-draft' != $post_status )
        $post_category = array( get_option('default_category') );
      else
      $post_category = array();
    }

    So you have to do it yourself. Second problem on Customs is you may assign more than one post_type to a Taxonomy. Which post_type is the default? So again you have to specify.

    To do what you want you would have to add an action on 'save_post' and in that action inspect the post_type and ecide if it's one you want then inspect the taxonomies and post_status to decide whether you need to add your default and use wp_set_object_terms() to add the default if needed.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.