Build classic and block WordPress themes from scratch: the template hierarchy, The Loop, the_title() and the_content(), template parts, menus, the Customizer, child themes and theme.json.
Lessons
The "posted on … by … in …" line under a post title is built from a handful of template tags for the date, author, categories, tags and comment count — and getting their output right matters for readers, accessibility and search engines.
<time class="entry-date" datetime="<?php echo esc_attr( get_the_date( DATE_W3C ) ); ?>">
<?php echo esc_html( get_the_date() ); ?>
</time>get_the_date() with no argument uses the date format chosen in Settings → General, so the site owner controls how dates read.datetime attribute holds a machine-readable date, which search engines and assistive technology use.get_the_modified_date() if you also want to show when a post was last updated.Watch out: Preferget_the_date()overthe_date()inside a Loop.the_date()prints the date only for the first post published on a given day — the second post that day shows no date at all. It is a historic quirk, not a bug you can fix.
<span class="byline">
<?php esc_html_e( 'by', 'gdc-starter' ); ?>
<a class="url fn n" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>">
<?php echo esc_html( get_the_author() ); ?>
</a>
</span>get_author_posts_url() links to the author archive, which renders with author.php (lesson 17).
<?php
/* translators: used between list items, there is a space after the comma. */
$separator = esc_html__( ', ', 'gdc-starter' );
$categories = get_the_category_list( $separator );
if ( $categories ) {
printf(
'<span class="cat-links">%1$s %2$s</span>',
esc_html__( 'Posted in', 'gdc-starter' ),
$categories // Already escaped by WordPress.
);
}
$tags = get_the_tag_list( '', $separator );
if ( $tags ) {
printf(
'<span class="tags-links">%1$s %2$s</span>',
esc_html__( 'Tagged', 'gdc-starter' ),
$tags // Already escaped by WordPress.
);
}The get_ list functions return complete, already-escaped HTML links. Each is checked before printing, so a post without tags does not show an empty "Tagged" label.
<?php if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) : ?>
<span class="comments-link">
<?php
comments_popup_link(
esc_html__( 'Leave a comment', 'gdc-starter' ),
esc_html__( '1 Comment', 'gdc-starter' ),
esc_html__( '% Comments', 'gdc-starter' )
);
?>
</span>
<?php endif; ?>You will print this meta line on archives, single posts and search results. Writing it three times means fixing bugs three times. Put it in a function — this is a pattern every well-built theme uses. Create inc/template-tags.php:
<?php
/**
* Custom template tags for GDC Starter.
*/
if ( ! function_exists( 'gdc_starter_posted_on' ) ) :
/**
* Prints the published date and author of the current post.
*/
function gdc_starter_posted_on() {
$time_string = sprintf(
'<time class="entry-date" datetime="%1$s">%2$s</time>',
esc_attr( get_the_date( DATE_W3C ) ),
esc_html( get_the_date() )
);
printf(
'<span class="posted-on">%1$s %2$s</span> <span class="byline">%3$s <a href="%4$s">%5$s</a></span>',
esc_html__( 'Posted on', 'gdc-starter' ),
$time_string, // Escaped above.
esc_html__( 'by', 'gdc-starter' ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_html( get_the_author() )
);
}
endif;Load it from functions.php with require get_template_directory() . '/inc/template-tags.php';, then every template simply calls <?php gdc_starter_posted_on(); ?>.
Tip: Thefunction_exists()wrapper is deliberate. It lets a child theme define its owngdc_starter_posted_on()first, replacing yours without editing the parent — "pluggable" functions, which you will use in lesson 27.
gdc_starter_posted_on() to inc/template-tags.php, load it, and call it under the title in single.php.In accordance with Section 6 & Section 7 of the DPDP Act 2023, third-party analytics and marketing trackers are strictly gated behind your affirmative consent. You may withdraw consent at any time under Section 6(4).
Essential for session authentication (ci_session), Cross-Site Request Forgery security (csrf_cookie_name), and Cloudflare DDoS/bot prevention. Cannot be disabled.
Gated under DPDP Section 7. Allows Google Analytics 4 (Google Consent Mode v2) to measure aggregate, anonymized tool usage.
Enables browser local storage to preserve your theme selection (dark/light mode) and code editor layout between visits.
Used to display developer sponsorships and native tool partner notices.