WordPress无法修改标题
问题描述:
我有一个安装了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));
}?>
答
我发现我的答案,在根文件夹我有相同的文件名一样,我想重定向的链接文件。
答
<?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。有关更多信息,请参阅代码中的此链接。