I am trying to change the height of my featured image to 350px in my child theme for Twenty Eleven.
Can anyone help??
Note: I am using Twenty Eleven and there is no functions.php file in my child theme, because the parent theme’s functions.php file is included after the child theme’s functions.php file.
When creating a child theme, you do not copy the functions.php file from the parent theme.
The only files I have in the child theme are style.css, header.css and footer.css.
I haven’t added any code yet for the change in height for the featured image because I don’t know what to put – would love some help.
If you want another size of the feature images in the Child theme than the parent theme you should add a functions.php file to the child theme and add specific functions for that theme.
From WordPress Codex about child theme functions.php
So lets say you want the child themes feature image size to be 150x150px you just add add_image_size to the childs functions.php file.
An example when the parent already have support for
post-thumbnails
you just add the thumbnail size:If you want more sizes only on the child theme you just add:
And then call it by:
you must create a child theme with a
functions.php
file and in the file include the followingthe last argument to the
add_action
call is the priority. Since this call will be made before the call from the parent theme you must make sure that the priority is higher than that of the parent theme so that the setup function of the child is run after that of the parent (if they have the same priority they will be run in registration order). Twentytwelve use the default priority, which is 10.If I understand your situation right, this is what you need to do.
Your parent theme being Twenty Eleven uses this function to create a custom image size:
You can filter the
twentyeleven_setup()
function to change the image sizeâbut that’s outside the scope of my coding knowledge. So, instead, we can create our own image size and use it.Create an empty functions.php file with the following code and drop it in your child theme directory (notice that the new function below has
350
and not300
âwhich is what you wanted):Now, copy the showcase.php file in your parent theme to your child theme’s directory. In it, replace this:
with this:
That should do it.