So i made a function which makes a custom post type named Blogs. The Blogs is used to:
- All Blogs
- Add New Blog
- Blog Categories
This is my function
function blog_post() {
$labels = array(
'name' => _x( 'Blogs', 'post type general name' ),
'singular_name' => _x( 'Blog', 'post type singular name' ),
'add_new' => _x( 'Add New Blog', 'blog' ),
'add_new_item' => __( 'Add New Blogs' ),
'edit_item' => __( 'Edit Blog' ),
'new_item' => __( 'New Blog' ),
'all_items' => __( 'All Blogs' ),
'view_item' => __( 'View Blog' ),
'search_items' => __( 'Search Blogs' ),
'not_found' => __( 'No blog found' ),
'not_found_in_trash' => __( 'No blog found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'Blogs'
);
$args = array(
'labels' => $labels,
'description' => 'Holds blogs and blog specific data',
'public' => true,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
'has_archive' => true,
);
register_post_type( 'blogs', $args );
}
add_action( 'init', 'blog_post' );
function blog_categories() {
$labels = array(
'name' => _x( 'Blog Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Blog Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Blog Categories' ),
'all_items' => __( 'All Blogs Categories' ),
'parent_item' => __( 'Parent Blog Category' ),
'parent_item_colon' => __( 'Parent Blog Category:' ),
'edit_item' => __( 'Edit Blog Category' ),
'update_item' => __( 'Update Blog Category' ),
'add_new_item' => __( 'Add New Blog Category' ),
'new_item_name' => __( 'New Blog Category' ),
'menu_name' => __( 'Blog Categories' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
);
register_taxonomy( 'categories', 'blogs', $args );
}
add_action( 'init', 'blog_categories', 0 );
This function defines my Blog custom post type.
So now i want a listing page for all the categories I have. How do I achieve that, any hint please?
So i made a function which makes a custom post type named Blogs. The Blogs is used to:
- All Blogs
- Add New Blog
- Blog Categories
This is my function
function blog_post() {
$labels = array(
'name' => _x( 'Blogs', 'post type general name' ),
'singular_name' => _x( 'Blog', 'post type singular name' ),
'add_new' => _x( 'Add New Blog', 'blog' ),
'add_new_item' => __( 'Add New Blogs' ),
'edit_item' => __( 'Edit Blog' ),
'new_item' => __( 'New Blog' ),
'all_items' => __( 'All Blogs' ),
'view_item' => __( 'View Blog' ),
'search_items' => __( 'Search Blogs' ),
'not_found' => __( 'No blog found' ),
'not_found_in_trash' => __( 'No blog found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'Blogs'
);
$args = array(
'labels' => $labels,
'description' => 'Holds blogs and blog specific data',
'public' => true,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
'has_archive' => true,
);
register_post_type( 'blogs', $args );
}
add_action( 'init', 'blog_post' );
function blog_categories() {
$labels = array(
'name' => _x( 'Blog Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Blog Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Blog Categories' ),
'all_items' => __( 'All Blogs Categories' ),
'parent_item' => __( 'Parent Blog Category' ),
'parent_item_colon' => __( 'Parent Blog Category:' ),
'edit_item' => __( 'Edit Blog Category' ),
'update_item' => __( 'Update Blog Category' ),
'add_new_item' => __( 'Add New Blog Category' ),
'new_item_name' => __( 'New Blog Category' ),
'menu_name' => __( 'Blog Categories' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
);
register_taxonomy( 'categories', 'blogs', $args );
}
add_action( 'init', 'blog_categories', 0 );
This function defines my Blog custom post type.
So now i want a listing page for all the categories I have. How do I achieve that, any hint please?
Share Improve this question edited Sep 9, 2019 at 16:26 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Sep 9, 2019 at 12:26 MaddoxStMaddoxSt 138 bronze badges 1 |1 Answer
Reset to default -1should create a template call blog.php then inside this file put this comemment
/* Template Name: Blog - wherever you want write
*/
copy page.php content here or do wherever you want
?>then go to wb interface create a new page named Blog and chose your blog template
/blogs/
. – Jacob Peattie Commented Sep 9, 2019 at 15:13