user3550879 user3550879 - 5 months ago 11
PHP Question

Linking to 'Home' from functions.php

I have the following code in my functions.php file (Wordpress)Which creates my back/next navigation. I want to add a link in the middle column (Bootstrap) which links to my home page

<?php if ( is_single() ) : // navigation links for single posts ?>

<?php previous_post_link( '<div class="col-xs-4"><div class="nav-previous">%link</div></div>', _x( '', 'Next post link', 'bnNav' ). '<span class="fa fa-chevron-left"></span><span class="back">BACK</span>'); ?>

<div id="test" class="col-xs-4"> ... Link to home ...</div>

<?php next_post_link( '<div class="col-xs-4"><div class="nav-next">%link</div></div>', '<span class="next">NEXT</span><span class="fa fa-chevron-right"></span>' . _x( '', 'Previous post link', 'bnNav' ) ); ?>



Wouldn't you simply put a link anchor - <a>?

<div id="test" class="col-xs-4">
    <a href="/">Home</a>

Alternatively - you could simply put your full url (i.e. instead of /.

A note: since you're using WordPress, you could also use get_home_url(); too:

<a href="<?php echo get_home_url(); ?>">Home</a>