Wordpress: Inserting Category headers into Page TITLE

时间:2015-04-23 05:20:26

标签: php wordpress

To provide better information to potential visitors to my site, I'd like to have the Categories listed in the page TITLE.

For example: Dead bankers list 2015 would appear as Dead bankers list 2015 | conspiracy, current affairs, higher form of life, insane, new world order, us bailout

Currently I'm able to use just one category header, but I'm aware people may be searching under any number of these to turn up my resource as a valid response.

1 个答案:

答案 0 :(得分:0)

You can define new title as per your requirement in template single.php

or you can add a filter as below

add_filter('the_title','some_callback');
function some_callback($data){
    global $post;
    // where $data would be string(#) "current title"
    // Example:
    // (you would want to change $post->ID to however you are getting the book order #,
    // but you can see how it works this way with global $post;)
    return 'Book Order # | ' . implode(',' , get_the_category( $post_id ));
}