08/26/2016   Comments Off on Automatic link to blog post page

View all snippets

Add this code to your functions.php file:

// Generate Link to posts page
function archi_get_post_page_url() {
  if( 'page' == get_option( 'show_on_front' ) ) {
    return get_permalink( get_option('page_for_posts' ) );
  } else { return home_url();}

And then in your theme file where you want the link to display:

<a href="<?php echo archi_get_post_page_url();?>">Back to all post page</a>