duanfen2008 2017-09-16 11:32
浏览 25
已采纳

在WordPress中将自定义帖子类型链接到自己的页面

I have a CPT called businesses and have created posts within that however, when I click on any of the posts, they show a blank page. Anyone know why?

<?php
//create a custom post type for new businesses
function create_businesses() {
      $labels = array(
        'name'                  => 'Our Businiesses',
        'singular_name'         => 'Our Businesses',
        'add_new_item'          => 'Add A New Business', 'chandco',
        'new_item'              => 'New Business', 'chandco',
        'edit_item'             => 'Edit Business', 'chandco',
        'view_item'             => 'View Business', 'chandco',
        'all_items'             => 'All Businesses', 'chandco',
        'add_new'               => 'Add A New Business', 'chandco'
      );
      $args = array(
        'labels' => $labels,
        'public' => true,
        'has_archive' => true,
        'capability_type' => 'post',
        'supports' => array('title', 'editor', 'thumbnail'),
        'rewrite' => array( 'slug' => 'businesses' ),
      );
    register_post_type( 'businesses', $args);
}
add_action( 'init', 'create_businesses' );
?>
  • 写回答

1条回答 默认 最新

  • dongren7374 2017-09-16 11:50
    关注

    According to Wordpress standard, this output will handle by the "single.php" file ( Common file for all posts single view ).

    But if you are getting blank page then you can try again by creating the specific file for the "businesses" custom post type posts.

    Create a file called "single-businesses.php" file. So now if you click on any of the posts, Wordpress will call this specific file and generate the output.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?