Soporte » Instalación – Actualizaciones » Problema con el header de un theme propio

  • He heredado un proyecto en el cual otra persona creo un theme y me salta un error en el header que no logro resolver:

    En el archivo: header.php Coloco esta función:

    <?php
    header(‘Content-Type: ‘.get_bloginfo(‘html_type’).’; charset=’.get_bloginfo(‘charset’));
    ?>

    Y me tira los siguiente dos errores:

    Warning: Cannot modify header information – headers already sent by (output started at /home/investinsa/domains/investinsantander.es/public_html/wp-content/themes/sodercan/functions.php:15) in /home/investinsa/domains/investinsantander.es/public_html/wp-includes/pluggable.php on line 1173

    El en archivo functions.php está creada esta función para el Sidebar
    /wp-content/themes/…/functions.php:15
    <?php

    // Main Sidebar
    if(function_exists(‘register_sidebar’)){
    register_sidebar(array(
    ‘name’ => ‘Main Sidebar’,
    ‘after_widget’ => »,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));
    }
    ?>

    Y en el archivo: pluggable.php me dice que en esta línea: status_header($status); // This causes problems on IIS and some FastCGI setups

    Hay otro error el propio WordPress ya me avisa de que puede causar error.

    /wp-includes/pluggable.php on line 1173
    function wp_redirect($location, $status = 302) {
    global $is_IIS;

    /**
    * Filter the redirect location.
    *
    * @since 2.1.0
    *
    * @param string $location The path to redirect to.
    * @param int $status Status code to use.
    */
    $location = apply_filters( ‘wp_redirect’, $location, $status );

    /**
    * Filter the redirect status code.
    *
    * @since 2.3.0
    *
    * @param int $status Status code to use.
    * @param string $location The path to redirect to.
    */
    $status = apply_filters( ‘wp_redirect_status’, $status, $location );

    if ( ! $location )
    return false;

    $location = wp_sanitize_redirect($location);

    if ( !$is_IIS && php_sapi_name() != ‘cgi-fcgi’ )
    status_header($status); // This causes problems on IIS and some FastCGI setups

    header(«Location: $location», true, $status);

    return true;
    }
    endif;

    Espero que puedan guiarme, muchas gracias.

Viendo 7 respuestas - de la 1 a la 7 (de un total de 7)
  • ¿Tienes instalado algún plugin de SEO?

    Saludos.

    Iniciador del debate pazgomlop

    (@pazgomlop)

    No, no tengo nada instalado. Es que además no me deja acceder a WP por /wp-admin

    He modificado el archivo functions.php Y tampoco funciona. Desde: function nueva_widgets_init() todo me da error.

    <?php

    if ( !function_exists( ‘nuevo_setup’ ) ) :

    // Registro del menú de WordPress
    function nuevo_setup() {

    register_nav_menus(array(
    ‘main’ => ‘Main’
    ));

    //Habilitar thumbnails
    add_theme_support(‘post-thumbnails’);
    set_post_thumbnail_size(150, 150, true);

    }

    endif;
    add_action( ‘after_setup_theme’, ‘nuevo_setup’ );
    ?>

    <?php

    function nuevo_widgets_init() {
    require get_template_directory() . ‘/inc/widgets.php’;
    register_widget( ‘nuevo_widget’ );

    register_sidebar(array(
    ‘name’ => ‘Main Sidebar’,
    ‘after_widget’ => »,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));

    register_sidebar(array(
    ‘name’ => »,
    ‘id’ => »,
    ‘after_widget’ => »,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));

    register_sidebar(array(
    ‘name’ => »,
    ‘id’ => »,
    ‘after_widget’ => »,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));

    register_sidebar(array(
    ‘name’ => »,
    ‘id’ => »,
    ‘after_widget’ => »,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));

    register_sidebar(array(
    ‘name’ => »,
    ‘id’ => »,
    ‘after_widget’ => »,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));

    register_sidebar(array(
    ‘name’ => »,
    ‘id’ => »,
    ‘after_widget’ => »,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));
    }
    add_action( ‘widgets_init’, ‘nuevo_widgets_init’ );

    Muchas gracias.

    Se tienen que resolver las cosas por partes, preguntando cosas diferentes y pegando código diferente no facilita las cosas para poder resolver una duda.

    Entonces vamos a resolver la duda por la cual abriste el tema.

    <?php
    header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
    ?>

    Suponemos que sin ese código que pegas, todo funciona bien. ¿Es así?

    ¿Porque razón pegas eso en el header.php del tema?
    ¿Que es lo que intentas hacer?

    Saludos.

    Iniciador del debate pazgomlop

    (@pazgomlop)

    ¿Porque razón pegas eso en el header.php del tema?
    El problema es que he «heredado» este proyecto, y sólo sé que el tema partió del theme básico de WP Twenty_Twelve, y no sé porqué pusieron ese código en el header.php Lo he quitado y sigue sin funcionar.

    ¿Que es lo que intentas hacer?
    Lo que intento es crear un nav-menu y unos sidebars.

    El error que me da ahora es en el archivo functions.php (donde hago las funciones para crearlos).

    Y al intentar acceder al panel de control de WP desde /wp-admin me tira esta línea de error:

    Warning: Cannot modify header information – headers already sent by (output started at /home/investinsa/domains/investinsantander.es/public_html/wp-content/themes/sodercan/functions.php:15) in /home/investinsa/domains/investinsantander.es/public_html/wp-includes/pluggable.php on line 1173

    No sé si necesitas más datos. Muchas gracias y un saludo.

    Ok.

    1- El código ese entonces no lo pones tu en el header, ya viene así el tema.
    2- Te marca un error en las funciones. ¿Sin poner las funciones que estas poniendo te da error?
    3- ¿Que funciones estas poniendo ahí?

    Saludos.

    Iniciador del debate pazgomlop

    (@pazgomlop)

    1- No, no el código en el header.php no lo pongo. Pero he comprobado que tampoco lo pide.

    2-Sin las funciones me da error.

    El en archivo functions.php está creada esta función para el Sidebar
    /wp-content/themes/…/functions.php:15

    <?php

    if ( !function_exists( ‘nuevo_setup’ ) ) :

    // Registro del menú de WordPress
    function nuevo_setup() {

    register_nav_menus(array(
    ‘main’ => ‘Main’
    ));

    //Habilitar thumbnails
    add_theme_support(‘post-thumbnails’);
    set_post_thumbnail_size(150, 150, true);

    }

    endif;
    add_action( ‘after_setup_theme’, ‘nuevo_setup’ );
    ?>

    <?php

    function nuevo_siderbar() {

    register_sidebar(array(
    ‘name’ => ‘Main Sidebar’,
    ‘after_widget’ => »,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));

    register_sidebar(array(
    ‘name’ => »,
    ‘id’ => »,
    ‘after_widget’ => »,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));

    register_sidebar(array(
    ‘name’ => »,
    ‘id’ => »,
    ‘after_widget’ => »,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));

    register_sidebar(array(
    ‘name’ => »,
    ‘id’ => »,
    ‘after_widget’ => »,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));

    register_sidebar(array(
    ‘name’ => »,
    ‘id’ => »,
    ‘after_widget’ => »,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));

    register_sidebar(array(
    ‘name’ => »,
    ‘id’ => »,
    ‘after_widget’ => »,
    ‘before_title’ => ‘<h3>’,
    ‘after_title’ => ‘</h3>’,
    ));
    }
    add_action( ‘nuevo_sidebar’ );

    Este es el código con el que genero el nuevo nav y los sidebar, la web funciona, pero no me deja acceder por /wp-admin, ni por /wp-login.php

    Gracias y un saludo.

    ¿Y sin esas funciones puedes entrar correctamente?

Viendo 7 respuestas - de la 1 a la 7 (de un total de 7)
  • El debate ‘Problema con el header de un theme propio’ está cerrado a nuevas respuestas.