Child theme functions.php do I use php open and close tags?

I setup a child theme which works fine. It’s importing the main style.css and has custom css styles along with custom header.php and footer.php files

When using functions.php in a child theme it’s going to append the child themes functions.php to the main theme. Do I need to wrap my functions in opening and closing php tags or can I just add the following without php tags add_image_size( 'related-thumbnail', 130, 130, true );

3 s
3

Opening tags are required, closing tags are only needed if you have other code (HTML, CSS) after them in the same file. See PHP manual.

A closing tag with nothing after it may lead to problems with included files if they contain a BOM. That’s one of the reasons why all optional closing tags were removed for WordPress 3.4 in core files. Follow this style. It’s useful.

Here is an example from Automattic’s _s theme’s functions.php.

Leave a Comment