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' );
?>
  • 写回答

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.

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

报告相同问题?

悬赏问题

  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考