Search code examples
wordpressadvanced-custom-fieldscustom-post-typecustom-wordpress-pages

Wordpress Custom post type displaying single.php instead of custom one


I'm having a problem in displaying a custom post type on a live Wordpress server, everything works fine in local but as soon as I upload the content on the live server instead of displaying my custom post it displays the single.php. Everything works fine and I can create custom posts directly from the dashboard, the content is present but it displays the single.php instead o the single-temp_keynoteSpeakers.php.

I'm using this plugin both on local and on the live server.

This is the Must use plugin I wrote:

<?php
function temp_post_types() {
    register_post_type('temp_news', array(
        'public' => true,
        'labels' => array('name' => 'News'),
        'menu_icon' => 'dashicons-megaphone',
        'add_new_item' => 'Add News',
        'edit_item' => 'Edit News'
    ));

    register_post_type('temp_keynoteSpeakers', array (
        'supports' => array('title', 'editor', 'thumbnail'),
        'public' => true,
        'labels' => array('name' => 'Keynote Speakers'),
        'menu_icon' => 'dashicons-microphone',
        'add_new_item' => 'Add Keynote Speaker',
        'edit_item' => 'Edit Keynote Speaker'
    ));
}

add_action('init', 'temp_post_types');
?>

I tried flushing the cache but it didn't work, I'm kind of lost right now and any kind of help would be greatly appreciated.


Solution

  • Tested your code, and used Query Monitor to see the template hierarchy: looks like the template's file name should be lowercase.

    screenshot of Query Monitor's Template panel