我有一個安裝了WordPress 4.6的網站,試圖在菜單項上點擊打開第一個子頁面。試圖做到這一點wp_redirect,但它不工作。WordPress無法修改標題
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-包括但不工作。我使用重定向
代碼:
<?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));
}?>