繁体   English   中英

WordPress无法修改标题

[英]WordPress cannot modify header

我有一个安装了WordPress 4.6的网站,尝试在菜单项上单击“打开第一个子页面”。 尝试执行wp_redirect,但无法正常工作。

Warning: Cannot modify header information - headers already sent by (output started at /home/content/65/9303265/html/wp-content/themes/ThemeName/page-gotochild.php:8) in /home/content/65/9303265/html/wp-includes/pluggable.php on line 1174

我试图删除空格和行并替换wp-admin和wp-includes,但是它不起作用。

我用来重定向的代码:

<?php
/*
    Template Name: Go to first child
*/
$pagekids = get_pages("child_of=".$post->ID."&sort_column=menu_order");
if ($pagekids) {
    $firstchild = $pagekids[0];
    wp_redirect(get_permalink($firstchild->ID));
}?>
<?php
/*
    Template Name: Go to first child
*/
$pagekids = get_pages("child_of=".$post->ID."&sort_column=menu_order");
if ($pagekids) {
   $firstchild = $pagekids[0];
   wp_redirect(get_permalink($firstchild->ID));
   exit;
}?>

进行重定向时,请始终尝试调用exit。 有关更多信息,请参见法典中的此链接。

“注意:wp_redirect()不会自动退出,并且应该几乎总是在其后调用退出;”:

我找到了答案,在根文件夹中,我有一个文件名与我要重定向的链接相同的文件名。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM