请在函数中输入以下代码。php文件。您需要创建名为“custom\\u post\\u name”的自定义字段,并将自定义字段文本设置为要添加到页面标题的内容。
function alter_page_title(){
global $post;
$current_page_title = $post->post_title;
/* Check if lower case version of current page title is = online exams. */
if (strtolower($current_page_title) == "online exams"){
/* If yes then get value of custom_post_name meta field and add that to beginning of title & return */
$custom_title_to_append = get_post_meta($post->ID, custom_post_name, true);
return $custom_title_to_append. " ".$current_page_title;
} else {
/* else return title as is */
return $post->post_title;
}
}
add_action(\'the_title\', \'alter_page_title\');