child index.php does not overwrite parent index.php in twenty fourteen theme

admin2025-01-07  6

I am using the twenty fourteen theme to create a child theme and want to make changes to the index.php, but when I copy the index.php file to the child theme's directory and edit it, it doesn't change my theme at all. Am I doing something wrong or missing something out? Thanks for any help

I have the following code to my child theme style sheet:

/*
Theme Name: Twenty Fourteen Child
Theme URI: 
Description: Child theme - Ecuador Travel Agency Tours Site
Author: Sarah Wyatt
Author URI: /
Template: twentyfourteen
Version: 1.0
Tags:
*/

And the following code to the child theme functions.php:

<?php

add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array('parent-style')
    );
}


?>

I am using the twenty fourteen theme to create a child theme and want to make changes to the index.php, but when I copy the index.php file to the child theme's directory and edit it, it doesn't change my theme at all. Am I doing something wrong or missing something out? Thanks for any help

I have the following code to my child theme style sheet:

/*
Theme Name: Twenty Fourteen Child
Theme URI: http://wordpress.org/themes/twentyfourteen
Description: Child theme - Ecuador Travel Agency Tours Site
Author: Sarah Wyatt
Author URI: http://www.onestopsolutionswebmasters.com/
Template: twentyfourteen
Version: 1.0
Tags:
*/

And the following code to the child theme functions.php:

<?php

add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array('parent-style')
    );
}


?>
Share Improve this question edited Mar 6, 2015 at 4:15 Pieter Goosen 55.4k23 gold badges115 silver badges209 bronze badges asked Mar 6, 2015 at 3:15 Sarah WyattSarah Wyatt 11 bronze badge 3
  • did you activate your child theme? what type of page are you trying to view? – Milo Commented Mar 6, 2015 at 3:25
  • Hi Sarah, welcome to WPSE and the SE network :-). Just a few tips to get you started. If you add code in the editor, highlight that code and look in the top right corner above the editor, there is a {} sign, click on that. That will add your code in a code block. Feel free to see How to Ask and visit help center for site related questions. Also, feel free to take a tour and learn how the SE sites operates – Pieter Goosen Commented Mar 6, 2015 at 4:14
  • what is the changed code in index.php of your child theme? – Michael Commented Mar 6, 2015 at 10:34
Add a comment  | 

1 Answer 1

Reset to default 0

The way you enqueueing your stylesheets are wrong. Someone very ignorant keeps changing my edit in the codex. The way you are doing this loads your child stylesheet twice. I have already done a post on this that you should check out here

The correct way is

add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {

    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

}

As for the problem with your index.php, you should clear all your caches, browser and plugin caches. This really seems like a cache problem as your code looks fine

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736264422a966.html

最新回复(0)