[英]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。 有關更多信息,請參見法典中的此鏈接。
我找到了答案,在根文件夾中,我有一個文件名與我要重定向的鏈接相同的文件名。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.