WordPress.org

Ready to get started?Download WordPress

Forums

Custom post type and display only child categories in "New post" page (1 post)

  1. eleonoraz
    Member
    Posted 2 years ago #

    Hi,
    I've created a custom post type called "News".

    My standard categories structure is the following:

    [ Moderator note: Fixed. Please don't post raw HTML here without using the code button. And don't use pre either, it kills the formatting. ]

    <ul>
    <li><strong>News</strong></li>
    </ul>
    <ul>
    <li>- Press Releases</li>
    <li>- Events</li>
    </ul>
    <li><strong>Products</strong></li>
    <ul>
    <li>- Smartphones</li>
    <li>- Tables</li>
    <li>- Audio</li>
    </ul>

    I've used the following code to automatically insert every custom post in the category News:

    function add_newscategory_automatically($post_ID) {
    	global $wpdb;
    	if(!wp_is_post_revision($post_ID)) {
    	$newscat = array (8);
    	wp_set_object_terms( $post_ID, $newscat, 'category');
    	}
    }
    add_action('publish_news', 'add_newscategory_automatically');

    Now I'd like to modify the category box on the right of the "New post" page, displaying only the "news" child subcategories.

    Anyone can help me?

Topic Closed

This topic has been closed to new replies.

About this Topic