WordPress Display Wrong Post Type

I have created CPT called ‘event’ and its working fine.
But i have other post type called ‘listing’.when i open any post from listing then it will display post type as event i don’t know whats happening.

This post has post type ‘listing’ and display as ‘event’. just because of this issue my all conditions are becoming wrong.

Read More

enter image description here

Can anyone help me please??

Thanks

For CPT – Event

//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();
}

For Default 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
            ) )
        );

Related posts