Reputation: 63
so I am working on a website for a friend right now. Right now I'm trying to figure out a good way to build a customizable staff section. So far I just created a custom template with a widget area, wrote a simple widget with name, age etc.
This works pretty decent so far. Now I'd like to have an extra "about me" page for each staff member.
Can I create a custom page somehow through a widget? Or would there be a better way of doing it?
Upvotes: 0
Views: 47
Reputation: 530
Your best bet is to use custom post types. Just like pages and regular posts you can create your own type of posts. You can create a 'staff' post type. This will add an extra menu item in your Wordpress backend for staff members. There are also multiple plugins available to create post types without using code, but if you can code I would recommend do it yourself. Simply put the following code in your theme's functions.php:
function create_staff_post_type() {
register_post_type( 'staff',
array(
'labels' => array(
'name' => __( 'Staff' ),
'singular_name' => __( 'Staff member' )
),
'public' => true,
'has_archive' => true,
'supports' => [
'title', 'editor', 'author', 'thumbnail',
'excerpt', 'trackbacks', 'custom-fields',
'comments', 'revisions', 'page-attributes',
'post-formats'
]
)
);
}
add_action( 'init', 'create_staff_post_type' );
After creating the post type you should reset the friendly URL's. You can do that by going to settings
->permalinks
and click the 'save' button (no need to change any option). This will make sure your new mysite.com/staff URL works.
This page will use your default archive page (or, if you don't have an archive page your index.php file) to generate the overview. If you want a customized template, simply create archive-staff.php and create your custom loop there. Same goes for the detail page, single-staff.php will give you a template for just this specific page.
Upvotes: 1