• Resolved chrispuxley

    (@chrispuxley)


    Hi Ben,

    I’m not a hugely experienced WordPress or Tracks user, but I’m trying to create a hybrid landing page – a top section that is a static page with site introduction and whatever content and styling I might want, followed by the ‘other style’ of home page with lovely post previews that make the theme so lovely. I’m not sure I fully understand the behaviour of the ‘front page’ and ‘posts page’ settings in the static front page customisation, but feel that I probably need to create a child theme to achieve what I want anyway.

    I have created a child theme (using my_change_homepage_category as a starting point so I can choose which posts will appear on the home page).

    Are you able to give me any guidance as I’m having a hard time unravelling the php – imagine this will be a change in index.php but with so many nested references I need a pointer to get started!

    Cheers,

    Chris

Viewing 1 replies (of 1 total)
  • Theme Author Ben Sibley

    (@bensibley)

    Hi Chris,

    Thanks for choosing Tracks!

    It sounds like you won’t need an entirely new template file for this since the blog page won’t be used elsewhere. Instead, we can inject the introductory content into the blog page.

    Tracks has a “tracks_main_top” hook that will be perfect for this. Check out this simple function:

    function my_homepage_content() {
    
      if( is_front_page() ) {
        echo '<div class="homepage-intro">';
        echo '<p>This is some custom text</p>';
        echo '</div>';
      }
    }
    add_action( 'my_homepage_content', 'tracks_main_top' );

    The function is attached to the tracks_main_top action “hook” which lets us add content right above the posts. The function checks if we’re on the front page and only outputs the content if that’s true. You can replace the HTML with whatever content you need to display and then style it via CSS. That whole function can be placed into the functions.php file in the child theme.

    In the Reading settings, you can leave it set to displaying your latest posts on the homepage.

    • This reply was modified 7 years, 10 months ago by Ben Sibley. Reason: clarification
Viewing 1 replies (of 1 total)
  • The topic ‘Creating child theme, with combined static page and posts display’ is closed to new replies.