My pages are using my Index.php and not my page.php

Viewed 168

So I'm making a custom theme, I setup the theme Created my pages on wordpress then created my Pages VS code i'll use an example of one page for this:

I created the talent page with the slug: talent

And a page-talent.php:

<?php
get_header();
?>
<div class="talent-arc container">
<?php echo do_shortcode('[visual_portfolio id="8"]'); ?>
</div>
<?php get_footer();?>

But its using my Index.php not the talent page, Ive never come accross this before usually its just create a page create the page-pagenamehere.php files and edit away

My Permalinnks are set to Post name:

My Functions PHP:

<?php 

add_theme_support( 'menus' );
add_theme_support( 'post-thumbnails' );

function wpt_excerpt_length( $length ) {
    return 70;
}
add_filter( 'excerpt_length', 'wpt_excerpt_length', 999 );

function register_theme_menus() {

    register_nav_menus(
        array(
            'primary-menu' => __( 'Primary_menu' ),
            'footer-menu' => __( 'Footer_menu' ),
            'extra-menu' => __( 'Extra_menu' )
        )
    );

}
add_action( 'init', 'register_theme_menus' );


function wpb_image_editor_default_to_gd( $editors ) {
    $gd_editor = 'WP_Image_Editor_GD';
    $editors = array_diff( $editors, array( $gd_editor ) );
    array_unshift( $editors, $gd_editor );
    return $editors;
}
add_filter( 'wp_image_editors', 'wpb_image_editor_default_to_gd' );

function wpt_theme_styles() {
    wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'bootstrap_css', get_template_directory_uri() . '/css/bootstrap.css' );
    wp_enqueue_style( 'bootstrap_css', get_template_directory_uri() . '/css/jquery-ui.min.css' );
    wp_enqueue_style( 'material_css', 'https://fonts.googleapis.com/icon?family=Material+Icons' );
}
add_action( 'wp_enqueue_scripts', 'wpt_theme_styles' );

function theme_js() {
            global $wp_scripts;
        wp_enqueue_script( 'bootstrap_js', get_template_directory_uri() . '/js/bootstrap.js', array('jquery'), '', false );
        wp_enqueue_script( 'jquery_ui_js', get_template_directory_uri() . '/js/jquery-ui.min.js', array('jquery'), '', false );
        wp_enqueue_script('custom_js', get_template_directory_uri(). '/js/script.js', array('jquery'), '', true);

    }

    add_action('wp_enqueue_scripts','theme_js');

    
function new_excerpt_more( $excerpt ) {
    return $excerpt. '... <a class="more-link" href="'. get_permalink( get_the_ID() ) . '">' . __('READ MORE') . ' </a>';
}
add_filter( 'get_the_excerpt', 'new_excerpt_more' );

function mytheme_setup() {
    add_theme_support('custom-logo');
}

add_action('after_setup_theme', 'mytheme_setup');



?>

CSS Template

/*
Theme Name:  KellyJeanCasting Theme
Author: 
Author URI:
Description: Theme for kelly
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags:
Text Domain: VSS
*/

Update: Renaming all my files from e.g talent to -> talent-main and adjusting the slugs makes it work, How do I remove that behaviour

1 Answers

Confirm that your page slug is talent and page-talent.php is located in the root of your theme folder.

You could also try to use the page ID for testing ie: if the talent page is #6 rename page-6.php

To make it a global template add the Template Name comment to the top of page-talent.php and then manually pick that template when editing the page.

<?php
/**
* Template Name: Talent Page
*/

https://developer.wordpress.org/themes/template-files-section/page-template-files/

Related