I have a WordPress project that I’m using as a CMS. I also have a database with some products in it that I’d like to display on the site (gallery or portfolio maybe?) I have a custom post type for Products that I want to be editable in the wordpress admin (along with the rest of the content).

I know I have to do a custom post type (which I’m reading up on, probably will use Simple Fields plugin) but I’m not seeing a way to pull these values from a database. Products will have ProductName, URL, Category, and Type. I would want to list and add/edit/delete these in the word press admin side of course.

Any advice will be greatly appreciated. Thank you all!

EDIT: I’ve created the Custom Post Type for Products. Now each Product can have a Category, Subcategory, and Type, which I’m assuming will also need their own Custom Post Type if they are to be manageable right?

The layout for the products will be roughly: ProductName, Type, Category, SubCategory, Document Name, Document URL. Remember the Category, SubCategory, Type will need to be manageable and editable so I guess they will need to be custom post types as well.

Thinking about this some more, could I use the built-in categories for MY custom post type categories and have the subcategories as children of the main categories? That might be the easier way out on that end. But how would I map a custom post type of ProductType to my custom post type of Product?

Here is my product custom post type:

    /*  CUSTOM POST TYPE AREA FOR PRODUCTS   */
add_action( 'init', 'create_product_post_type' );

function create_product_post_type() 
{
    $labels = array(
        'name' => _x('Products', 'post type general name'),
        'singular_name' => _x('Product', 'post type singular name'),
        'add_new' => _x('Add New', 'products'),
        'add_new_item' => __('Add New Product'),
        'edit_item' => __('Edit Product'),
        'new_item' => __('New Product'),
        'view_item' => __('View Product'),
        'search_item' => __('Search Products'),
        'not_found' => __('No products found'),
        'not_found_in_trash' => __('No products found in Trash'),
        'parent_item_colon' => '',
        'menu_name' => 'Products'           
        );

    $args = array(
        'label' => __('Products'),
        'labels' => $labels,
        'public' => true,
        'can_export' => true,
        'show_ui' => true,
        '_builtin' => false,
        'capability_type' => 'post',
        'menu_icon' => get_bloginfo('template_url').'/functions/images/product.png',
        'hierarchial' => false,
            //'rewrite' => array( "slug" => "events" ),
        'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),
        'show_in_nav_menus' => true

        );

        register_post_type( 'tf_events', $args);    
}

2 Answers
2

What you really need to do is create Custom Taxonomies for your products instead of second custom post type. You can create taxonomies that are hierarchical like categories, or non-hierachical like tags. Give them names, slugs, etc.

This way you won’t interfere with the blog categories and tags, and get a more customized result.

Leave a Reply

Your email address will not be published. Required fields are marked *