'Wordpress custom plugin open a page
I will try to explain it this way: I am developing my own custom post type plugin. So I have a menu on the admins page to create different post types (News, Jobs, Media...).
adding the menu:
add_menu_page('Post Type Page', 'Posting', 'manage_options', 'posting', 'posting','dashicons-groups', $position ='4');
add_submenu_page( 'posting', 'News','News','manage_options', 'news_list', 'post_news');
add_submenu_page( 'posting', 'Jobs','Jobs', 'manage_options', 'jobs_list', 'post_job');
.....
If the admin clicks now News menu item, I want a page to open with a button on top 'create new News' and than a list of all created news.
If the admin clicks Jobs menu item, I want a page to open with a button on top 'create new Job' and than a list of all created jobs.
this is the code:
function post_news(){
echo 'News';
echo '<form id="post" method="POST" action=""><br><br><button class="button" name="create_posting">Create new News</button><br><br><input name="post_type" type="hidden" value="news"></form>';
echo get_posting_list('news');
}
So far everythibg works.
Now I want to create different template pages to create the post (different data for Jobs than for News).
If the admin clicks the 'create new News' button I want a new page to open with the form to create a news post. And if he clicks 'create new Jobs' button the template for jobs should open. But in the menu on the left side the menu item 'News' or 'Jobs' has to stay active. So only the content has to change.
The templates are saved in the folder 'pages' in the plugin folder.
How can I make this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
