{"id":6259,"date":"2018-04-19T14:23:31","date_gmt":"2018-04-19T14:23:31","guid":{"rendered":"https:\/\/blog.hostinger.io\/mx-tutoriales\/?p=6259"},"modified":"2023-05-29T12:17:11","modified_gmt":"2023-05-29T10:17:11","slug":"solucionar-warning-cannot-modify-header-information-headers-already-sent-by","status":"publish","type":"post","link":"\/mx\/tutoriales\/solucionar-warning-cannot-modify-header-information-headers-already-sent-by\/","title":{"rendered":"Solucionar &#8220;Warning: cannot modify header information \u2013 headers already sent by&#8221;"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Si te has encontrado con el error de WordPress &#8220;<strong>Warning: cannot modify header information \u2013 headers already sent by<\/strong>&#8220;, eso significa que hay algo mal en el c\u00f3digo del encabezado de la p\u00e1gina de tu sitio web. No te preocupes, estamos aqu\u00ed para ayudarte. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">En este art\u00edculo, explicaremos por qu\u00e9 se produce este error y c\u00f3mo solucionarlo en un abrir y cerrar de ojos.<\/p>\n\n\n\n\n\n<h2 class=\"wp-block-heading h-t-title-2\" id=\"h-por-que-aparece-el-error-cannot-modify-header-information-headers-already-sent-by\">Por qu\u00e9 aparece el error &#8216;Cannot modify header information \u2013 headers already sent by&#8217;<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">En WordPress, este error se produce cuando hay un c\u00f3digo defectuoso en el header de tu p\u00e1gina. Por ejemplo, el mensaje se ver\u00e1 parecido a esto:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Warning: Cannot modify header information \u2013 headers already sent by (output started at \/public_html\/wp-content\/plugins\/my-plugin\/my-function.php:#) in \/public_html\/wp-includes\/pluggable.php on line #<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Normalmente se mencionan dos archivos y el origen del problema proviene del primero, que impide que el otro funcione correctamente. Mientras tanto, la l\u00ednea # indica la ubicaci\u00f3n del c\u00f3digo defectuoso, lo que te ayuda a localizar el problema sin tener que recorrer el archivo manualmente.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">En la mayor\u00eda de los casos, la existencia de espacios en blanco adicionales o enviar el output antes de llamar al header primero causa el error. Con la ayuda de la informaci\u00f3n del mensaje de error, deber\u00edas poder resolver este problema en poco tiempo.<\/p>\n\n\n\n<h2 class=\"wp-block-heading h-t-title-2\" id=\"h-solucionar-cannot-modify-header-information-headers-already-sent-by\">Solucionar &#8216;Cannot modify header information \u2013 headers already sent by&#8217;<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Los errores tipogr\u00e1ficos, una configuraci\u00f3n incorrecta del software y una mala ubicaci\u00f3n del header son algunas de las causas m\u00e1s comunes de este error.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A continuaci\u00f3n, se explica c\u00f3mo solucionar el mensaje de WordPress &#8220;<strong>Warning: cannot modify header information \u2013 headers already sent by<\/strong>&#8220;:<\/p>\n\n\n\n<h3 class=\"wp-block-heading h-t-title-3\" id=\"h-1-editar-archivos-danados\">1. Editar archivos da\u00f1ados<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Si el archivo defectuoso tiene espacios en blanco, la forma m\u00e1s f\u00e1cil de resolver el problema es editarlo manualmente a trav\u00e9s de un <a data-click-id=\"hgr-post-content-link-ftp\" href=\"\/mx\/tutoriales\/configurar-filezilla\/\">FTP<\/a> o del Administrador de archivos. Puedes empezar desde la <strong>l\u00ednea #<\/strong> mencionada en el mensaje de error, y luego buscar en el resto del archivo cualquier espacio innecesario.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Aseg\u00farate de prestar especial atenci\u00f3n al principio y al final de las etiquetas PHP. No debe haber espacios antes de la etiqueta <strong>&lt;?php <\/strong>o despu\u00e9s de la etiqueta <strong>?&gt;<\/strong> y de la \u00faltima l\u00ednea de c\u00f3digo.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Muchos editores de texto pueden eliminar los espacios en blanco autom\u00e1ticamente. Como alternativa, puedes utilizar herramientas online de correcci\u00f3n de espacios en blanco como <a data-click-id=\"hgr-post-content-link-textfixer\" href=\"https:\/\/www.textfixer.com\/tools\/remove-white-spaces.php\" target=\"_blank\" rel=\"noopener\">TextFixer<\/a> y <a data-click-id=\"hgr-post-content-link-code-beautify\" href=\"https:\/\/codebeautify.org\/remove-extra-spaces\" target=\"_blank\" rel=\"noopener\">Code Beautify<\/a> que hagan el trabajo por ti.<\/p>\n\n\n\n<h3 class=\"wp-block-heading h-t-title-3\" id=\"h-2-reemplazar-archivos-danados\">2. Reemplazar archivos da\u00f1ados<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Si el error &#8220;<strong>Warning: cannot modify header information \u2013 headers already sent by<\/strong>&#8221; se origina en un plugin o tema, puedes solucionarlo f\u00e1cilmente reinstalando el software. Si se trata de un archivo del n\u00facleo de WordPress, la mejor soluci\u00f3n es sustituir el archivo defectuoso por una versi\u00f3n nueva y reiniciar el sitio web. La nueva instalaci\u00f3n generar\u00e1 el archivo adecuado autom\u00e1ticamente.<\/p>\n\n\n\n<h3 class=\"wp-block-heading h-t-title-3\" id=\"h-3-reubicar-la-sentencia-del-header\">3. Reubicar la sentencia del header<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Por defecto, el header debe ser llamado primero antes de enviar cualquier output del body. Enviar un output antes de llamar al header, incluyendo tener secciones HTML no parseadas en el archivo PHP, posiblemente cause el error. As\u00ed es como se ve un c\u00f3digo incorrecto:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;html&gt;\n&lt;?php\nheader('Location: http:\/\/www.hostinger.com\/');\n?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Para resolver este problema, debes encontrar las sentencias que env\u00edan el output encima del header. Luego, mueve la sentencia del header por encima de la sentencia defectuosa y haz las modificaciones necesarias al c\u00f3digo seg\u00fan corresponda.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a data-click-id=\"hgr-post-content-link-mx-hosting-wordpress\" aria-label=\"Hosting wordpress\" href=\"\/mx\/hosting-wordpress\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/39\/2024\/06\/ES-New-WP_in-text-banner.png\/public\" alt=\"\" class=\"wp-image-40615\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/39\/2024\/06\/ES-New-WP_in-text-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/39\/2024\/06\/ES-New-WP_in-text-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/39\/2024\/06\/ES-New-WP_in-text-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/39\/2024\/06\/ES-New-WP_in-text-banner.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading h-t-title-2\" id=\"h-conclusion\">Conclusi\u00f3n<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Ya sea que pegues un fragmento de c\u00f3digo en tu archivo, insertes un nuevo plugin\/plantilla o escribas c\u00f3digo manualmente, corres el riesgo de agregar espacios en blanco adicionales al archivo. Si te descuidas, esto puede desencadenar el error &#8220;<strong>Warning: cannot modify header information \u2013 headers already sent by<\/strong>&#8220;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u00bfTe ha resultado \u00fatil nuestro tutorial para resolver este error de WordPress? H\u00e1znoslo saber en la secci\u00f3n de comentarios m\u00e1s abajo.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Si te has encontrado con el error de WordPress &#8220;Warning: cannot modify header information \u2013 headers already sent by&#8220;, eso significa que hay algo mal en el c\u00f3digo del encabezado de la p\u00e1gina de tu sitio web. No te preocupes, estamos aqu\u00ed para ayudarte. En este art\u00edculo, explicaremos por qu\u00e9 se produce este error y [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/mx\/tutoriales\/solucionar-warning-cannot-modify-header-information-headers-already-sent-by\/\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":85,"featured_media":6260,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"Solucionar 'Warning: cannot modify header information \u2013 headers already sent by'","rank_math_description":"Si ves el error \"warning: cannot modify header information - headers already sent by\", debes revisar tus archivos WordPress. \u00a1Te ayudamos a solucionarlo!","rank_math_focus_keyword":"warning: cannot modify header information - headers already sent by","_content_updated_date":"","footnotes":""},"categories":[14542,14504],"tags":[14107],"class_list":["post-6259","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-seguridad-y-mantenimiento","category-wordpress","tag-warning-cannot-modify-header-information-headers-already-sent-by"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-fix-cannot-modify-header-information-error-in-wordpress\/","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/como-corrigir-warning-cannot-modify-header-information-headers-already-sent-by\/","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/solucionar-warning-cannot-modify-header-information-headers-already-sent-by\/","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/cannot-modify-header-information-headers-already-sent-by\/","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-fix-cannot-modify-header-information-error-in-wordpress","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-fix-cannot-modify-header-information-error-in-wordpress\/","default":0},{"locale":"en-GB","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-fix-cannot-modify-header-information-error-in-wordpress","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-fix-cannot-modify-header-information-error-in-wordpress\/","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-fix-cannot-modify-header-information-error-in-wordpress","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-fix-cannot-modify-header-information-error-in-wordpress","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-fix-cannot-modify-header-information-error-in-wordpress\/","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/solucionar-warning-cannot-modify-header-information-headers-already-sent-by\/","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/solucionar-warning-cannot-modify-header-information-headers-already-sent-by\/","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/solucionar-warning-cannot-modify-header-information-headers-already-sent-by\/","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/como-corrigir-warning-cannot-modify-header-information-headers-already-sent-by\/","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/mx\/tutoriales\/wp-json\/wp\/v2\/posts\/6259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/mx\/tutoriales\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/mx\/tutoriales\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/mx\/tutoriales\/wp-json\/wp\/v2\/users\/85"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/mx\/tutoriales\/wp-json\/wp\/v2\/comments?post=6259"}],"version-history":[{"count":16,"href":"https:\/\/www.hostinger.com\/mx\/tutoriales\/wp-json\/wp\/v2\/posts\/6259\/revisions"}],"predecessor-version":[{"id":32479,"href":"https:\/\/www.hostinger.com\/mx\/tutoriales\/wp-json\/wp\/v2\/posts\/6259\/revisions\/32479"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/mx\/tutoriales\/wp-json\/wp\/v2\/media\/6260"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/mx\/tutoriales\/wp-json\/wp\/v2\/media?parent=6259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/mx\/tutoriales\/wp-json\/wp\/v2\/categories?post=6259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/mx\/tutoriales\/wp-json\/wp\/v2\/tags?post=6259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}