2016-08-06 32 views
1

我想添加一个title元素到特定页面(不是所有页面)。我正在使用Yoast,但我无法在Yoast插件上找到此页面。所以我想我必须将它添加到PHP文件头部分。但我的头部部分如下所示,我该如何添加它?如何将<title>元素添加到WordPress的特定页面上?

<?php 
/** 
* The template for displaying all single jobs. 
* 
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post 
* 
* @package WorkSt 
*/ 

get_header(); ?> 

然后在下面是HTML,例如,容器等。

回答

0

您可以通过wp_head钩的WordPress的

add_action('wp_head', 'add_custom_meta'); 

function add_custom_meta(){ 
    global $post; 
    if('your-page-slug' === $post->post_name){  
     echo '<meta content="your content">'; // add mete here 
    } 
} 
可以向该
相关问题