Wordpress:自定义<title>用于存档页面 [英] Wordpress: Custom &lt;title&gt; for archive pages

查看:37
本文介绍了Wordpress:自定义<title>用于存档页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在修改存档页面的页面标题时遇到了一些麻烦.我有一个自定义的电影帖子类型,我似乎无法改变它.现在它读取电影档案".我想将其完全更改为程序"之类的内容.

I'm having a little trouble modifying the page title for my archive pages. I have a custom post type for movies, and I can't seem to alter it. Right now it reads "Movies archive". I'd like to change it altogether to something like "Programme".

有什么想法吗?

谢谢!

推荐答案

这取决于您的模板用于输出自定义帖子类型存档标题的功能.

It depends on the function your template is using to output the title of your custom post type archive.

我猜它正在使用 wp_titleget_the_archive_title 以便您可以尝试添加过滤器(在 主题的functions.php):

function movies_archive_title( $title ) {

    if(is_post_type_archive('movie'))
        return 'Programme';

    return $title;
}
add_filter( 'wp_title', 'movies_archive_title' );
add_filter( 'get_the_archive_title', 'movies_archive_title' );

如果查看的页面是电影档案(请务必将 'movie' 替换为您自定义帖子类型名称的确切名称),然后将标题替换为 Programme.

If the page viewed is the movies archive (be sure to replace 'movie' with the exact name of your custom post type name) then it replace the title with Programme.

这篇关于Wordpress:自定义<title>用于存档页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆