admin管理员组文章数量:1309146
I'm trying to change title and meta description for pages used for products.
The goal is to have the same effect as here:
<script>document.title = "<?php echo $new_title; ?>";</script>
The page with lists of products is a template where are includes in some conditions.
template_listing.php:
if (!empty($offer['listingId']))
include('include_offer.php');
I'm struggling with how to change title/description in include_offer.php. My findings so far:
function wp1_filter_wp_title($title) {
if (is_page_template('include_offer.php')) {
return 'some title';
}
return $title;
}
add_filter('pre_get_document_title', 'wp1_filter_wp_title');
But it doesn't work. It's working only if if (is_page_template('template_listing.php'))
.
Is there any function like 'is_page_template' which also works for included pages?
Edit:
function show_template() {
global $template;
echo basename($template);
}
basename on that single product page return 'template_listing.php'
I also figured out there is function get_included_files
but I'm not sure how to use that in my case.
本文标签: phpChange title and meta description in included page (not template)
版权声明:本文标题:php - Change title and meta description in included page (not template) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741811309a2398811.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论