My WordPress site uses a child-theme (of the default twenty-sixteen) and now I would like to insert a new line into the single.php file.

I know that it’s better to use the functions.php file of the child-theme than inserting the new line directly into the parent theme’s single.php file. (Correct me if I’m wrong.)

I would be grateful if somebody could show me how to do it properly. I would like to insert this line

<div class="fb-comments" data-href="https://wordpress.stackexchange.com/questions/212498/<?php the_permalink(); ?>" data-numposts="5"></div>

into the

<div id="primary" class="content-area">

element, right above the closing

</main>

tag in the single.php file.

1
1

your child theme
can override any file in the parent theme: simply include a file of
the same name in the child theme directory, and it will override the
equivalent file in the parent theme directory when your site loads
.

with the exception:

Unlike style.css, 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.)

Source

in your case, just copy single.php to your child theme and do your edits.

Leave a Reply

Your email address will not be published. Required fields are marked *