Question

I have to create a module for admin where admin can manage the post. suppose i have to create 3 post types

  1. New added post type
  2. Entertainment Post type
  3. Featured post type

when any user add any post then this post come can be add into the "New added post type" or "Entertainment Post type", which will be show in the admin module for the respective post type module to manage by admin.

so main issue is if admin want to show any post in the "featured post type" then admin can do this.

as per my concern admin can switch this post to "featured post type". and this post is remove from "old post type".

so main issue is i want to show this post in to both post type in the front end for front end users as well as back end module for admin user.

Was it helpful?

Solution

This is fact that a single can not be two types because in the Database we can store only a single value for this.

But according to your case I don't think this is a difficult task. You have only the problem of back end that you are unable to show a post under two types. You do not need to create different post types for each.

just create a category and add post in to the category

1) category 1
2) category 2
3) category 3
4) category 4

you can create multiple category and subcategory and you can assign multiple category to a single post

the main thing for you to get the separate module as per category then you can add following code to get the separate module for each category dynamically

Just need to focus on this.....

following code will be show menu of category which are parent category then you can manage separately

<?php
/***
** plugin name,description
*/
/************* plugin code ************/
$cpost = new CUST_POST();
class CUST_POST{

    public function __construct()
    {
    $this->pluginname      = 'Manage Posts';
    add_action('admin_menu', array(&$this,'admin_myplugin_menu')); 
    }

    function admin_myplugin_menu(){
    $cats = get_categories();


        if ($cats) {
         $i = 0;
        foreach($cats as $k=>$cat) {
            if($cat->category_parent == 0){
            if($i == 0){
                // if the first then show as main menu
                add_menu_page(__($this->pluginname, $this->pluginname), __($this->pluginname, $this->pluginname), 'mp', 'mp', ''));
            }
            // show as submenu
            add_submenu_page('mp', $cat->name." Posts", $cat->name." Posts", "administrator", 'edit.php?category_name='.$cat->slug, '');
            $i++;
            }
        } 

        }

    }

}
?>

Hopefully . it will be helpful.

OTHER TIPS

There is a great plugin Post Type Switcher that gives you simple way to change a post type in WordPress.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top