Obteniendo Titulo en WordPress para todas las secciones

Si necesitas obtener correctamente los títulos de las páginas dentro de wordpress aqui te dejo la función que encontre hace mucho tiempo y aún me sigue funcionando.

<?php
/** titulo **/
    function filter_wp_title( $title, $separator ) {
        // Don't affect wp_title() calls in feeds.
        if ( is_feed() )
            return $title;
    
        // The $paged global variable contains the page number of a listing of posts.
        // The $page global variable contains the page number of a single post that is paged.
        // We'll display whichever one applies, if we're not looking at the first page.
        global $paged, $page;
    
        if ( is_search() ) {
            // If we're a search, let's start over:
            $title = sprintf( __( 'Search results for %s' ), '"' . get_search_query() . '"' );
            // Add a page number if we're on page 2 or more:
            if ( $paged >= 2 )
                $title .= " $separator " . sprintf( __( 'Page %s' ), $paged );
            // Add the site name to the end:
            $title .= " $separator " . get_bloginfo( 'name', 'display' );
            // We're done. Let's send the new title back to wp_title():
            return $title;
        }
    
        // Otherwise, let's start by adding the site name to the end:
        $title .= get_bloginfo( 'name', 'display' );
    
        // If we have a site description and we're on the home/front page, add the description:
        $site_description = get_bloginfo( 'description', 'display' );
        if ( $site_description && ( is_home() || is_front_page() ) )
            $title .= " $separator " . $site_description;
    
        // Add a page number if necessary:
        if ( $paged >= 2 || $page >= 2 )
            $title .= " $separator " . sprintf( __( 'Page %s' ), max( $paged, $page ) );
    
        // Return the new title to wp_title():
        return $title;
    }
    add_filter( 'wp_title', 'filter_wp_title', 10, 2 );
?>

Para usarlo solo debes colocar en el header, entre las etiquetas title:

<title><?php wp_title( '|', true, 'right' );    ?></title>

 

¡Comparte!

Facebook
Twitter
WhatsApp
LinkedIn

Enseño como usar herramientas digitales y los trucos para generar ingresos online.

1 comentario en “Obteniendo Titulo en WordPress para todas las secciones”

  1. Es muy gratificante cuando se localizan blogs de excelencia y que dan gran valor, si no hay contrariedad voy propagarlo en mi
    Facebook y por cierto me apunto el vínculo.

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Post Recientes

¿Necesitas generar ventas?

Hey!, soy Xuxan Vigo y llevo años ayudando a los negocios a crecer, actualmente busco compartir todo lo que tengo este conocimiento.

Olvidate del SPAM, se te enviará lo prometido. Las actualizaciones de mi web en artículos, seminarios, plantillas y más.

¿Listo para aprender, emprender y mas?

Recibe solo contenido Interesante al unirte a mi gran comunidad:

Artículos de Marketing Digital

Atento a las próximas videoconferencias

Plantillas para planificar tus estrategias

No te lo pierdas

Déjanos tus datos!

Olvidate del SPAM, se te enviará lo prometido. Las actualizaciones de mi web en artículos, seminarios, plantillas y más.