duanfen2008
2017-09-16 19: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' );
?>

图片转代码服务由CSDN问答提供 功能建议

我有一个名为business的CPT并在其中创建了帖子但是,当我点击任何帖子时,他们 显示空白页面。 有谁知道为什么?

 &lt;?php 
 //为新企业创建自定义帖子类型
_function_businesses(){
 $ labels = array(
'  name'=&gt;'我们的业务'',
'singular_name'=&gt;'我们的业务',
'add_new_item'=&gt;'添加新业务','chandco',
'new_item'=&gt;  '新业务','chandco',
'edit_item'=&gt;'编辑业务','chandco',
'view_item'=&gt;'查看业务','chandco',
'all_items'=&gt  ;'所有业务','chandco',
'add_new'=&gt;'添加新业务','chandco'
); 
 $ args = array(
'labels'=&gt; $ labels,  
'public'=&gt; true,
'has_archive'=&gt; true,
'ability'type'=&gt;'post',
'支持'=&gt;数组('title','editor',  'thumbnail'),
'重写'=&gt;数组('slug'=&gt;'商家'),
); 
 register_post_  type('business',$ args); 
} 
add_action('init','create_businesses'); 
?&gt; 
   
 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongren7374 2017-09-16 19: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.

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题