Child Theme functions.php problem solved
-
Other server details:
PHP version 5.4.37
Running on linux Apache version 2.2.26
MySQL version 5.5.40-36.1My system is Win 7 latest update(s)
Browser Firefox 35.0.1 (IE latest and Chrome latest are available if necessary)I have an existing WP installation 4.1.1 with an older theme located in the main directory. This system is functioning well except for some updating problems with the theme and the theme software (html and php upgrade problems).
The client would like to have a new look and a website where everything works.
I installed a second WP on subdirectory /xyz/ and it works well there.
The client wants some changes to the 2015 theme, and I tried to install a child theme to make those changes.The child theme 2015-child is in place, but my function.php was apparently incorrect. It did not let the 2015-child work and printed the code of functions.php on the top of every page WP can open (website display and admin pages).
Here is the code I put in the functions.php file:
add_action( "wp_enqueue_scripts", "enqueue_parent_styles" ); function enqueue_parent_styles() { wp_enqueue_style( "parent-style", get_template_directory_uri()."/style.css" ); }
I am not a PHP pro – but in spite of that, I finally figured out that to make that work I need to have an opening and closing PHP tag before and after the above code.
I figured out that I need is
<?php
on the front end with nothing – not even a blank space – before the “<” and a close for the PHP tag at the end, which is
?>
again, with absolutely nothing after that.It might be worth while for someone else to place that in the code examples for the functions.php file here and there. It would have saved me about 4 or 5 hours.
- The topic ‘Child Theme functions.php problem solved’ is closed to new replies.