2016-08-06 33 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 
    } 
} 
可以向該
相關問題