• Hey guys! I’m so happy to be developing my own website with WORDPRESS.

    I want to move the previous/next links on the bottom of each post up above the box that takes new comments, so that they go right after the end of the actual text of the article. I guess I just need to cut and paste some stuff in the .php files? But I’m having a bit of trouble getting the nuts and bolts of it, and after several hours of looking, cannot locate the right bit of code to move and am unsure where to move it to.

    I’m using a twenty fifteen child theme (just dif colors and fonts for a few things, no big changes).

    If someone could give me a hand, I would appreciate it! Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Please post a link to a relevant page.

    Thread Starter pwnUN33bers

    (@pwnun33bers)

    Yeah, sorry, the page is my personal page and has my name in the URL so I’m not really wanting to post it if I can avoid it, at least not right now.

    It’s just a basic twenty-fifteen. I’m confused which files I should be modifying… it seems like this change (though many people would want it?) is rather hairy to implement. The problem seems to be that the comments.php template file gets called in the content block, but the prev/next link functions get called after the content block, so I’m going to have to inject them into the basic content function?? Or am I misunderstanding? TBH I just started with WordPress last week so it’s a bit fuzzy.

    Is there a way to look at the call stack that executes when wordpress generates the html files, so I can know exactly which functions in which files get called? I’m from a more conventional programming background (C, C++ and Java) and that’s generally what I would do, but I’m not sure if that’s how people go about things with wordpress.

    The generic advice is not to edit core files because updates will be lost when updating.

    Instead, WordPress provide software hooks of which there are many:
    https://codex.www.ads-software.com/Plugin_API/Action_Reference

    Hooks have a priority parameter which can be used to affect their sequence. You would use the remove_action hook to remove the element where you don’t want it, then an add_action hook to add it back in where you do want it. The hook codes go in functions.php for your child theme.

    Alternatively you can create a new page template and there is advice out there on how to do that. Personally I’d try the hook approach first.

    I’ve not come across using a call stack in WordPress development.

    Thread Starter pwnUN33bers

    (@pwnun33bers)

    Thanks, lorro! That definitely clears things up as far as what I need to do.

    I’ll post what I did after I get it figured out, in case anyone else wants to have a look.

    Might take a few days, but this is the type of thing that really gives you a deeper understanding of such programs and can make future alterations so much easier.

    Thread Starter pwnUN33bers

    (@pwnun33bers)

    Got it taken care of.

    I used the debug objects plugin to look at all the hooks. There were a lot of calls to different stuff for the comments, so I figured it would be easier to just add links above the comments and delete the ones in the original position, below.

    I looked at single.php to get the code to make the links pretty, but then realized I could just cut and paste the call to the_post_navigation() in single.php, placing it above the comments.

    Yeah so actually it was pretty simple. The single.php won’t get overwritten, right? Because it’s in my child folder?

    So if anyone else wants to fix this, open single.php and cut

    the_post_navigation( array(
    				'next_text' => '<span class="meta-nav" aria-hidden="true">' . __( 'Next', 'twentyfifteen' ) . '</span> ' .
    					'<span class="screen-reader-text">' . __( 'Next post:', 'twentyfifteen' ) . '</span> ' .
    					'<span class="post-title">%title</span>',
    				'prev_text' => '<span class="meta-nav" aria-hidden="true">' . __( 'Previous', 'twentyfifteen' ) . '</span> ' .
    					'<span class="screen-reader-text">' . __( 'Previous post:', 'twentyfifteen' ) . '</span> ' .
    					'<span class="post-title">%title</span>',
    			) );

    And paste it above this part:

    // If comments are open or we have at least one comment, load up the comment template.
    			if ( comments_open() || get_comments_number() ) :

    TBH I feel like the wordpress documentation actually made this entire process more difficult. There’s just so much of it, and so many seemingly redundant functions with similar names, that you end up having to look at the code itself or using the debug objects plugin to know what’s going on in YOUR site. Hence, I kind of feel like looking at the documentation at all was kind of a waste of time.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Move prev/next links right below post body’ is closed to new replies.