2

So I want to move my comments section to the left of my content in my Twentythirteen child theme. I've located where it's pulled from in the content.php file:

        <?php if ( comments_open() && ! is_single() ) : ?>
        <div class="comments-link">
            <?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a comment', 'twentythirteen' ) . '</span>', __( 'One comment so far', 'twentythirteen' ), __( 'View all % comments', 'twentythirteen' ) ); ?>
        </div><!-- .comments-link -->
    <?php endif; // comments_open() ?>

    <?php if ( is_single() && get_the_author_meta( 'description' ) && is_multi_author() ) : ?>
        <?php get_template_part( 'author-bio' ); ?>
    <?php endif; ?>

Trouble is I'm not too sure where to move it too in terms of other php files? I've moved my secondary widget area to the left of the content (rather than the default right). Is there a way I can make a widget use this code and still work?

Thanks!

Edit: So I tried using the PHP Code Widget and C&P the above code it but it doesn't display anything :(

2
  • "Too left of" isn't specific enough. And what is the significance of widgets? – s_ha_dum Dec 23 '15 at 15:45
  • Secondary widget area is the right sidebar to the content. I've used some php to move it to the left, which is where I want the comments section to go; rather than in the footer. – OllyhatesFYP Dec 23 '15 at 15:50
1

Comments aren't in the "footer", they are in the Loop, and they need to be to keep their association with the parent post. That is why you are having trouble. You are moving them out of the context that Core expects. What you are going to have to do, I think (and I haven't tested this), is explicitly pass the post ID to the relevant functions-- comments_open() and is_single().

if ( comments_open($post->ID) && ! is_single($post->ID) ) :
2
  • (My php ability is pretty poor so you'll have to excuse my ignorance), would you say that this line of code needs to go at the beginning of the content of the pulled code from the php file in order for it to work? – OllyhatesFYP Dec 23 '15 at 16:26
  • Look at the function calls in my code then in the code you posted. – s_ha_dum Dec 23 '15 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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