Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php WordPress显示错误的帖子类型_Php_Wordpress - Fatal编程技术网

Php WordPress显示错误的帖子类型

Php WordPress显示错误的帖子类型,php,wordpress,Php,Wordpress,我已经创建了名为“事件”的CPT,它工作正常。 但是我有另一个帖子类型叫做'listing'。当我打开列表中的任何帖子时,它会将帖子类型显示为事件,我不知道发生了什么 此帖子具有帖子类型“listing”并显示为“event”。正是因为这个问题,我的所有条件都变得不正确。 谁能帮帮我吗 谢谢 对于CPT-事件 //Create Custom Post type (CPT) Event add_action('init', 'ntvs_register_questions'); functio

我已经创建了名为“事件”的CPT,它工作正常。 但是我有另一个帖子类型叫做'listing'。当我打开列表中的任何帖子时,它会将帖子类型显示为事件,我不知道发生了什么

此帖子具有帖子类型“listing”并显示为“event”。正是因为这个问题,我的所有条件都变得不正确。

谁能帮帮我吗

谢谢

对于CPT-事件

//Create Custom Post type (CPT) Event
add_action('init', 'ntvs_register_questions');

function ntvs_register_questions() {
    //$icon_url = plugin_dir_url(__FILE__).'/images/askengage_qG1.png';
    $labels = array(
        'menu_name' => __('Events', 'quest'),
        'name'      => __('Event', 'quest'),
        'add_new'   => __('Add New', 'Event'),
        'add_new_item' => __('Add New Event'),
        'edit_item' => __('Edit Event'),
        'all_items' => __('All Events'),
        'view_item' => __('View Event')
    );
    $args = array(
        'labels' => $labels,
        //'menu_icon' => $icon_url,
        'hierarchical' => true,
        'description' => 'Holds event & its specific data',
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => array('slug' => 'event'),
        'capability_type' => 'post'
    );
    register_post_type('event', $args);
    flush_rewrite_rules();
}
对于默认的PT-Listing

/**
         * Post types
         */
        $singular  = __( 'Job', 'wp-job-manager' );
        $plural    = __( 'Jobs', 'wp-job-manager' );

        if ( current_theme_supports( 'job-manager-templates' ) ) {
            $has_archive = _x( 'jobs', 'Post type archive slug - resave permalinks after changing this', 'wp-job-manager' );
        } else {
            $has_archive = false;
        }

        $rewrite     = array(
            'slug'       => _x( 'job', 'Job permalink - resave permalinks after changing this', 'wp-job-manager' ),
            'with_front' => false,
            'feeds'      => true,
            'pages'      => false
        );

        register_post_type( "job_listing",
            apply_filters( "register_post_type_job_listing", array(
                'labels' => array(
                    'name'                  => $plural,
                    'singular_name'         => $singular,
                    'menu_name'             => __( 'Job Listings', 'wp-job-manager' ),
                    'all_items'             => sprintf( __( 'All %s', 'wp-job-manager' ), $plural ),
                    'add_new'               => __( 'Add New', 'wp-job-manager' ),
                    'add_new_item'          => sprintf( __( 'Add %s', 'wp-job-manager' ), $singular ),
                    'edit'                  => __( 'Edit', 'wp-job-manager' ),
                    'edit_item'             => sprintf( __( 'Edit %s', 'wp-job-manager' ), $singular ),
                    'new_item'              => sprintf( __( 'New %s', 'wp-job-manager' ), $singular ),
                    'view'                  => sprintf( __( 'View %s', 'wp-job-manager' ), $singular ),
                    'view_item'             => sprintf( __( 'View %s', 'wp-job-manager' ), $singular ),
                    'search_items'          => sprintf( __( 'Search %s', 'wp-job-manager' ), $plural ),
                    'not_found'             => sprintf( __( 'No %s found', 'wp-job-manager' ), $plural ),
                    'not_found_in_trash'    => sprintf( __( 'No %s found in trash', 'wp-job-manager' ), $plural ),
                    'parent'                => sprintf( __( 'Parent %s', 'wp-job-manager' ), $singular )
                ),
                'description' => sprintf( __( 'This is where you can create and manage %s.', 'wp-job-manager' ), $plural ),
                'public'                => true,
                'show_ui'               => true,
                'capability_type'       => 'job_listing',
                'map_meta_cap'          => true,
                'publicly_queryable'    => true,
                'exclude_from_search'   => false,
                'hierarchical'          => false,
                'rewrite'               => $rewrite,
                'query_var'             => true,
                'supports'              => array( 'title', 'editor', 'custom-fields', 'publicize' ),
                'has_archive'           => $has_archive,
                'show_in_nav_menus'     => false
            ) )
        );

你能发布你用来定义自定义帖子类型的代码吗?它在更新wp主题之前起作用,但在更新wp主题之后不起作用,列表是主题的默认帖子类型,其中as event是CPTT这很好,但它仍然不允许我们看到你看到的内容。我们看不见你的电脑。您需要共享代码,以便任何人都能帮助您。您缺少列表的register post type命令。您可以发布用于定义自定义帖子类型的代码吗?它在更新wp theme之后工作,但在更新wp theme之后不工作,列表是theme的默认帖子类型,其中as event是cpt这很好,但它仍然不允许我们看到你所看到的。我们看不见你的电脑。您需要共享代码,以便任何人都能帮助您。您缺少列表的register post type命令。