我有一个安装了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));
}?>