0

So i made a function which makes a custom post type named Blogs. The Blogs is used to:

  1. All Blogs
  2. Add New Blog
  3. 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?

  • 1
    The page is generated automatically at /blogs/. – Jacob Peattie Sep 9 at 15:13
-1

should 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.