A few small additions that don't fit neatly into any single earlier lesson, but come up often enough in real theme builds to be worth collecting here.
By default, wp_head() outputs a few things most sites don't need — a meta tag announcing the exact WordPress version (a minor information-disclosure risk) and legacy links few tools still use:
<?php
remove_action( 'wp_head', 'wp_generator' ); // WordPress version meta tag
remove_action( 'wp_head', 'rsd_link' ); // legacy remote-publishing link
remove_action( 'wp_head', 'wlwmanifest_link' ); // legacy Windows Live Writer link
None of this changes how the site looks or behaves for a visitor — it just trims a handful of lines a browser never renders anyway.
WordPress has no built-in breadcrumb function. A small custom one, called from within a template, covers the common case:
<?php
function mytheme_breadcrumb() {
echo '<nav aria-label="Breadcrumb"><ol>';
echo '<li><a href="' . esc_url( home_url( '/' ) ) . '">Home</a></li>';
if ( is_page() && $post->post_parent ) {
echo '<li><a href="' . esc_url( get_permalink( $post->post_parent ) ) . '">' . esc_html( get_the_title( $post->post_parent ) ) . '</a></li>';
}
echo '<li aria-current="page">' . esc_html( get_the_title() ) . '</li>';
echo '</ol></nav>';
}
Called simply as <?php mytheme_breadcrumb(); ?> anywhere in page.php or single.php. Real sites usually extend this to also handle single posts' categories and archive pages — this covers the shape, not every branch.
A custom field storing a phone number or email as plain text still needs the right href scheme to actually be clickable as a phone call or email draft — easy to forget on a busy contact page with several such links:
<?php
function mytheme_contact_href( $value ) {
if ( is_email( $value ) ) {
return 'mailto:' . antispambot( $value );
}
$digits = preg_replace( '/[^\d+]/', '', $value );
return $digits ? 'tel:' . $digits : '';
}
<?php $phone = get_field( 'phone_number', 'option' ); ?>
<a href="<?php echo esc_attr( mytheme_contact_href( $phone ) ); ?>"><?php echo esc_html( $phone ); ?></a>antispambot() is a built-in WordPress function that obfuscates an email address's HTML slightly, to make it a little harder for basic scrapers to harvest — a small, free precaution worth using anywhere an email address is printed in plain sight.
Small, optional, worth doing anyway
None of these three are required — a site works without them. They're the kind of small polish that separates a theme that merely functions from one that feels finished, and every one of them lives in exactly one place: functions.php.
With the theme functionally complete, the final lesson in this section covers what's left before handing it to a client or pushing it live.