• Resolved komiska

    (@komiska)


    Combed everything there is online about front-page.php vs index.php, setting static pages etc. read all the Codex references time and again. There seem to be no answer to the following, and it has been days now of trial and errors, but to no avail.

    I have a front-page.php set as the static front page of the WordPress site. In it there is a link that I’d like to link to the home.php or index.php.

    How do I write the url?

    <a href='<?php echo esc_url( home_url()); ?>' title='<?php echo esc_attr( get_bloginfo( 'title' ) ); ?>' rel='home'>

    What do i write instead of home_url(), which lands me of course on the front-page.php ?

    I have also tried the get_permalink for 'page_for_posts', but that lands me again on the starting page.

    This is really complicating the theme development, as there seem to be no way to write a link from the static front page to the index.php or home.php

    Thank you very much for your help!

    • This topic was modified 7 years, 9 months ago by komiska.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey komiska,

    Have you set the posts page under Settings -> Reading?

    If so you should be able to do something like:

    <a href="<?php echo get_permalink( get_option( 'page_for_posts' ) ); ?>">Blog Page</a>

    or from 4.5:

    <?php $posts = get_post_type_archive_link( 'post' ); ?>

    Hope this helps

    Thread Starter komiska

    (@komiska)

    YES! OMG thank you!

    But WHY?! i thought, if i have an actual PAGE set as a Posts Page, and if it uses the Standard Template it would be page.php , not index.php / home.php. or did I get that part wrong?

    I also tried setting the Blog page as Posts Page before, but then i just got linked to that empty page titled Blog, which means it was using the page.php Template and not the home.php.

    Also, this did not work, as opposed to your <?php echo.. function:
    <a href='<?php echo esc_url( get_permalink( get_option( 'page_for_posts' ) ) ); ?>'

    WHY?
    i guess that’s a topic for a whole book chapter…

    THANK YOU, thank you!

    Hey komiska,

    Glad that you got it working.

    Ye, it’s a little confusing. When you set a page to the “Posts Page” it no longer uses the page.php or custom template assigned.

    It starts to use the home.php or index.php template hierarchy.

    https://developer.www.ads-software.com/themes/basics/template-hierarchy/ covers this in a bit more detail and might help.

    All the best

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Linking front-page.php to home.php’ is closed to new replies.