Hi bcworkz,
It is difficult to dive into the WP way and try to get a grasp on POSTS, PAGES, CUSTOM POSTS, CATEGORIES, TAXONOMIES, etc etc. and how they relate.
I am having a difficult time ordering my plugin so that my links and everything looks neat. So for instance, in the URL bar you would see: /vcos/course/lesson1, where each link actually has content that the plugin provides. However after searching (a lot) I found that you can do this by creating CATEGORIES instead of TAXONOMIES (which probably can be used as well somehow). SO, I’m looking for a way to dynamically create my CATEGORIES under the PARENT CATEGORY “vcos” based on the courses in my “courses” table.
Ok, so what I’ve done so far is to create a menu in the admin:
add_action( 'admin_menu', 'register_vcos_menu_page' );
function register_vcos_menu_page(){
add_menu_page( 'vcOS', 'vcOS', 'edit_theme_options', 'vcos', 'vcos_admin_menu', plugins_url( 'vcos/images/icon.png' ), 30 );
}
Then I created a table in the WP database and called it “courses”. So I created custom post types using my table “courses” to list the courses depending on who the user/author is.
//QUERY COURSES FOR CURRENT USER WITHIN ADMIN
add_action( 'init', 'codex_custom_init' );
function codex_custom_init() {
global $wpdb;
global $current_user;
$current_user = wp_get_current_user();
$userid = $current_user->ID;
//Get user's courses
$queries = $wpdb->get_results("SELECT courseid, course FROM ".$wpdb->prefix."vcos_courses WHERE ownerid='$userid'");
foreach ($queries as $query){
$course = $query->course;
$courseid = $query->courseid;
$args = array(
'public' => true,
'label' => $course,
'show_ui' => true,
'hierarchical' => true,
'taxonomies' => array('category'),
'show_in_menu' => 'vcos',
'rewrite' => array('slug' => $course = $query->course),
'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'page-attributes', 'tags')
);
register_post_type( $courseid, $args );
}
wp_register_style( 'vcos', plugins_url('/css/style.css', __FILE__), false, '1.0.0', 'all');
}
I don’t know if that’s the best way to go about it, but the menu is working.
BTW, I am looking for anybody interested in the development of vcOS (just in case).
Thanks again.