Locating Global Variables

Child themes

The WordPress Way of modifying the theme’s page-templates/front-page.php is to create a child theme, then duplicate this file in the child theme and make the modifications there. Your modified template file will be loaded instead of the parent theme’s file.

This allows the parent theme to be updated without losing the modifications made to the template. The only real drawback here is that your child theme’s copied template will not reflect any updates made to the parent theme’s front-page.php. So, you’d have to manually update your modified template in the event that the parent theme’s corresponding file is changed. It’s best to only duplicate the parent theme’s templates that you want to modify. This keeps the maintenance burden to a minimum.

the_title()

The way that the_title() works is, while in the WordPress loop, e.g.:

if ( have_posts() ) {
    while ( have_posts() ) {
        the_post(); ?>

        <h1><? the_title(); ?></h1>

        <?php
        // ...
    }
} else {
    // no posts
}

the_title() will echo the title for the current post in the loop. Note that echo the_title(); is incorrect since the output will be automatically echo’d. There is a similar function, get_the_title() that does not automatically echo the output.

the_title() is using the global $post variable which is set for each iteration in the loop using the_post(). Generally this is what is happening when the_post() is called within the loop:

the_post() --> 

WP_Query::the_post(); --> 

global $post;
$post = WP_Query::next_post();
WP_Query::setup_postdata( $post ); -->

$post = get_post( $post );

the_title() is then using get_the_title() which is grabbing $post->post_title, which is the title of the current post in the loop.

The Global Variables Codex page has a (partial) list of global variables used in WordPress.