无法修改wordpress中的标题信息 [英] Cannot modify header information in wordpress

查看:134
本文介绍了无法修改wordpress中的标题信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法修改
上的wordpress标题信息警告:无法修改标题信息 - 已经发送的标题(输出开始于/ home / sixtydev / public_html / voxxydev / wp-content / themes / voxxy /home/sixtydev/public_html/voxxydev/wp-includes/pluggable.php on line 865



我的重定向代码是:

  if(isset($ _ GET ['qry'])&&!empty($ _ GET ['qry'])){ 
$ swl = mysql_query(update wp_share_idea set image。$ _ GET ['qry']。=''where userId ='。$ delId。');

wp_redirect(http://60degreedeveloper.info/voxxydev/user-profile/?msg='。$ delId。');
出口;

}

我的header.php代码:

 <?php 
/ **
*我们主题的标题。
*
*显示所有< head>部分和所有东西直到< div id =main>
*
* @package WordPress
* @subpackage Voxxy
* @since Voxxy 1.0
* /
?>< html>
< head>
< title> Voxxy< / title>
< link rel =profilehref =http://gmpg.org/xfn/11/>
line no:15 ::< link rel =stylesheettype =text / cssmedia =allhref =<?php bloginfo('stylesheet_url');?>/> ;
< link rel =pingbackhref =<?php bloginfo('pingback_url');?>/>

和plugable.php代码:

 函数wp_redirect($ location,$ status = 302){
global $ is_IIS;

$ location = apply_filters('wp_redirect',$ location,$ status);
$ status = apply_filters('wp_redirect_status',$ status,$ location);

if(!$ location)//允许wp_redirect过滤器取消重定向
return false;

$ location = wp_sanitize_redirect($ location); $!

if(!$ is_IIS&& php_sapi_name()!='cgi-fcgi')
status_header($ status); //这会导致IIS和一些FastCGI设置出现问题
line no:865: - header(Location:$ location,true,$ status);
}

我很困惑,问题出在哪里。
在此先感谢

解决方案

wp_redirect 这是在Wordpress中生成输出的第一件事。它通过在输出中设置http头来工作。一旦其他东西产生了一些输出,那个方法就不再起作用了。



在你的情况下,无论你在pluggable.php中调用重定向代码,都发生在<$ c已经调用了$ c> get_header()。

您必须在调用标头之前移动此代码,或者使用javascript函数来重定向用户。

你也不应该在你的数据库上执行一个 update 查询来处理unsanitized $ _GET变量。


I have a problem with Cannot modify header information in wordpress on Warning: Cannot modify header information - headers already sent by (output started at /home/sixtydev/public_html/voxxydev/wp-content/themes/voxxy/header.php:15) in /home/sixtydev/public_html/voxxydev/wp-includes/pluggable.php on line 865

my redirection code are :

if(isset($_GET['qry'])  && !empty($_GET['qry'])){
    $swl = mysql_query("update wp_share_idea set image".$_GET['qry']."='' where userId='".$delId."'");

    wp_redirect("http://60degreedeveloper.info/voxxydev/user-profile/?msg='".$delId."'");
    exit;

} 

my header.php code:

<?php
/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till <div id="main">
 *
 * @package WordPress
 * @subpackage Voxxy
 * @since Voxxy 1.0
 */
?><html>
<head>
<title>Voxxy</title>
<link rel="profile" href="http://gmpg.org/xfn/11"/>
line no: 15:: <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('stylesheet_url');?>"/>
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>"/>

and plugable.php code:

function wp_redirect($location, $status = 302) {
    global $is_IIS;

    $location = apply_filters('wp_redirect', $location, $status);
    $status = apply_filters('wp_redirect_status', $status, $location);

    if ( !$location ) // allows the wp_redirect filter to cancel a redirect
        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
line no:865:-   header("Location: $location", true, $status);
}

I am get confused that where is the problem occured. Thanks in advance

解决方案

wp_redirect will only work if it is the first thing to generate output in Wordpress. It works by setting the http header in the output. Once something else has generated some output, that method no longer works.

In your case, wherever you're calling your redirect code in pluggable.php occurs after get_header() has been called.

You've either got to move this code before your header gets called, or use a javascript function to redirect the user.

You should also NEVER run an update query on your database on an unsanitized $_GET variable.

这篇关于无法修改wordpress中的标题信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆