So I've built several sites like this, using a child theme to be able to customize what I want.
This time, I have a child theme directory with a style.css and functions.php, etc.
The style sheet overrides fine, even the header.php I added overrides. However, index.php will not override the parent theme's index.php.
Anyone have any ideas?
It sounds like you've set everything up correctly, from the fact that your header.php is overriding the parent theme.
The index.php template is the final fallback if Wordpress cannot find a more appropriate template to use. Most likely, it's selecting another template from the parent theme - eg. archive.php, frontpage.php, home.php, single.php - or many others depending on which particular URL you are viewing.
This visual overview of Wordpress' template hierarchy will help you understand how it works. Using this, you should be able to locate which template file is being selected in the parent theme and therefore, which one you need to override.
Related
Same as title, i want require file 'foo.php' before wordpress require 'functions.php' in theme. What's solution? Somebody can help me?
Use a Child Theme.
Basically you just do this:
Create a directory in your themes directory to hold the child theme.
The theme directory is wp-content/themes. You should name the
directory without any space as part of the name, and it is common
practice to use the name of the parent theme folder with “-child”
appended to it. For example, if you are making a child of the
twentyfourteen theme, your folder name would be twentyfourteen-child.
Inside, you can create a functions.php and add the code you want, you can even call other files, like your foo.php:
(...) the functions.php of a child theme does not override its counterpart
from the parent. Instead, it is loaded in addition to the parent’s
functions.php. (Specifically, it is loaded right before the parent’s
file.)
You can also create a plugin, they are loaded before functions.php, you can take a look at the loading order here: https://wordpress.stackexchange.com/questions/26537/between-functions-php-widgets-and-plugins-which-is-loaded-first
It seems that an edited copy of shortcodes.php in child-theme of mezzanine flat theme is not working (does not override the parent theme)
I tried copying the whole lib folder where shortcodes.php is located but still not working. Is there anything I need to do to make it work? Other common pages of wordpress (i.e. header and page) override smoothly on child pages.
Thanks in advance.
You can't override shortcodes.php because the child theme replace only template files
But you can create a new file, like custom_shortcodes.php with your custom shortcode, save in your child theme and then include it in functions.php ( include 'custom_shortcodes.php'; )
In order to overwrite some CSS of an existing Wordpress theme, I would like to create a child theme of it as described on http://codex.wordpress.org/Child_Themes#Example_of_a_basic_Child_Theme .
I created a directory along with the style.css file, where the parent theme's name is defined as "template". So far, so good. When I go to the themes page in Wordpress' administration, I get the message "The [name of parent theme] theme is not a valid parent theme.", and I cannot activate it.
I am wondering how Wordpress finds out if a parent theme is valid or not and if there is a way to make the parent theme a valid parent theme.
In order to find out if the defined parent theme is the problem, I replaced the "template" definition with another theme, which is also installed on the same server, and that worked.
Thanks in advance for your help.
It seems I forgot to mention the fact that caused the problem: My parent theme is already a child theme, and I was not aware of the two generation limit, which means that a child child theme is not possible. :-(
Thanks for your help anyway! Maybe this information should be added on http://codex.wordpress.org/Child_Themes ...
try checking your child theme's css and look at the #import line and make sure there is a ';' semicolon at the end. :)
Your child theme needs to use exactly the same name (same cases, same spaces etc.) as the parent theme. It's defined as Theme Name in the parent's style.css.
Does anyone have experience with Gantry Framework?
I am wondering if it is possible to create a child theme based off of the default? Where would I put my css file and can I build off of the current css instead of starting from scratch while still separating my css from the default theme?
Apart from the usual process of creating a WordPress child theme (create a directory, with proper style.css and functions.php), Gantry requires a specific procedure.
You'll need to copy two files from the parent directory to the child theme directory, keeping the structure:
/gantry/theme.yaml
and
/includes/theme.php
Then, edit the copied theme.yaml: the parent must be your parent theme directory name.
On the theme.php, select all text and replace with this:
// Initialize theme stream.
$gantry['platform']->set(
'streams.gantry-theme.prefixes',
array('' => array(
"gantry-themes://{$gantry['theme.name']}/custom",
"gantry-themes://{$gantry['theme.name']}",
"gantry-themes://{$gantry['theme.name']}/common",
"gantry-themes://{$gantry['theme.parent']}",
"gantry-themes://{$gantry['theme.parent']}/common"
))
);
As for css, you must create this file, within your child theme directory:
/custom/scss/custom.scss
It can be formatted in either SCSS or CSS, and will override the theme's core style sheet files.
Creating a Child Theme is very easy.
All you need to do is create a directory in your theme directory, and name it something like "Gantry-child". Inside that folder, add a file called "style.css". Once this is done, you just need to add the Theme Information that tells Wordpress the Child Theme's Name, Author, and Parent Theme.
Inside the new style.css, add:
/*
Theme Name: Gantry Child
Template: rt_gantry_wp
*/
The most important part that lets Wordpress know that this is a child of the Gantry Theme is the "Template" section. This is the name of the PARENT directory in your Themes folder.
What this will do is create a new theme that inherits all of the parent theme's functions. If you also want to inherit the existing parent theme stylesheet, add to style.css:
#import url("../rt_gantry_wp/style.css");
Hopefully this should get you started. Once that's done, you can add your own header, footer, index, functions, or anything else you can think of to extend the parent theme's functionality.
Hopefully this helps get you started.
I would like to create new page (with specific style) on child theme. I created a page.php on child theme, however, it doesn't work. Instead of, parent theme's pape.php does.
When I remove the parent theme's pape.php, it redirects index.php.
Can I create new page.php on child theme in wordpress?
Sounds strange. As i understood you can overload all the files in your parent-theme from the child-theme by just creating a new -filename-.php. Here is som good reading Wordpress Child Theme