Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need to create a child theme for the default Twenty Fourteen theme. And in this child theme, I need to modify the single.php.

This is the default single.php

get_header(); ?>

    <div id="primary" class="content-area">
        <div id="content" class="site-content" role="main">
                // Start the Loop.
                while ( have_posts() ) : the_post();

                     * Include the post format-specific template for the content. If you want to
                     * use this in a child theme, then include a file called called content-___.php
                     * (where ___ is the post format) and that will be used instead.
                    get_template_part( 'content', get_post_format() );

                    // Previous/next post navigation.

                    // If comments are open or we have at least one comment, load up the comment template.
                    if ( comments_open() || get_comments_number() ) {
        </div><!-- #content -->
    </div><!-- #primary -->

get_sidebar( 'content' );

I now need to do two things:

First, Add some sharing buttons in my post. The codes for these buttons are

<div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a></div>

<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdPic":"","bdStyle":"0","bdSize":"16"},"share":{},"image":{"viewList":["qzone","tsina","tqq","renren","weixin"],"viewText":"分享到:","viewSize":"16"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["qzone","tsina","tqq","renren","weixin"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>

Second, Add some variable from Advanced Custom Fields in the post. The codes are like:

<p><?php the_field('field_name'); ?></p>

I don't know where to add these codes. I tried to insert theme between some lines, but that causes the theme to stop working.

I need to know, where to add these lines of codes.

share|improve this question
What do you try actually to do and what have you tried? it is very possible you are trying to make your changes in the wrong file. –  Mark Kaplun Feb 12 '14 at 6:20
I tried to modify the single.php file. I don't want to edit the content file since it also changes the appearance of the front page and archive page and the search result page. I only want to add some things to the Full Post page. –  Leopold Feb 12 '14 at 6:22
The changes need to go to the content file or you need to write a plugin that changes the content via the the_content filter (or do it in your theme's functions.php file). –  Mark Kaplun Feb 12 '14 at 6:44
Another option you might consider is to hook in both your sharing buttons and ACF tag using a custom function with hook and conditional tag from your child themes functions file rather than hard code them into your template files. –  Brad Dalton Feb 15 '14 at 2:04

1 Answer 1

Modifying any core files in wordpress is a big NO NO, As when the new update of wordpress roll out, your changes to files like single.php or any files, will be lost. The best way and recommended way is to make child theme. In that folder you may copy the template you need, in your case single.php and do edit in that file.
Never ever make a edit in core wordpress file!

share|improve this answer
Where did you read something about modifying core files? The question is about a child (!) theme of TwentyFourteen. –  t f Feb 12 '14 at 8:44
@tf read the question! 'He is asking where can i add the code' and 'he wants to edit single.php', hitting negative is easy then to read between lines! –  Nofel Feb 12 '14 at 9:09
The questions starts with I need to create a child theme for the default Twenty Fourteen theme. And in this child theme, I need to modify the single.php.. So, where exactly is this core file you're talking about? –  t f Feb 12 '14 at 9:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.