Template Tags

Los Template Tags son funciones de WordPress que se usan directamente en los archivos de plantilla del tema (header.php, single.php, archive.php…) para imprimir contenido dinámico: títulos, contenido, imágenes, menús, etc.

¿Dónde se usan?

Dentro del Loop o en los archivos de plantilla del tema. No en functions.php (que es para registrar, no para mostrar).

Los más usados

<?php the_title(); ?>           <!-- Título del post actual -->
<?php the_content(); ?>         <!-- Contenido completo -->
<?php the_excerpt(); ?>         <!-- Extracto (primeras palabras) -->
<?php the_permalink(); ?>       <!-- URL del post -->
<?php the_ID(); ?>              <!-- ID del post -->
<?php the_date(); ?>            <!-- Fecha de publicación -->
<?php the_author(); ?>          <!-- Nombre del autor -->
<?php the_post_thumbnail(); ?>  <!-- Imagen destacada -->
<?php the_custom_logo(); ?>     <!-- Logo del tema -->
<?php wp_nav_menu(); ?>         <!-- Menú de navegación -->
<?php wp_head(); ?>             <!-- Scripts/metas del head (obligatorio) -->
<?php wp_footer(); ?>           <!-- Scripts del footer (obligatorio) -->
<?php body_class(); ?>          <!-- Clases CSS dinámicas del body -->
<?php get_template_part(); ?>   <!-- Incluye fragmento de plantilla -->

the_ vs get_the_ — diferencia clave

// the_ → hace echo directamente
the_title(); // imprime: Mi título

// get_the_ → devuelve el valor para usarlo en PHP
$titulo = get_the_title();
echo '<title>' . esc_html( $titulo ) . ' | Mi Sitio</title>';

// Necesitas get_ cuando quieres el valor en un atributo HTML:
<img alt="<?php echo esc_attr( get_the_title() ); ?>">

Ejemplo en una plantilla

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header>
        <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
        <time><?php the_date(); ?></time>
    </header>
    <?php the_post_thumbnail( 'medium' ); ?>
    <div class="contenido">
        <?php the_excerpt(); ?>
    </div>
</article>