Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1203187
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 2 years ago.
Improve this questionI'm writing a custom Wordpress theme and for a specific page I need to overwrite its meta-tags (printed by YoastSEO) with the meta-tags of another page I already know the ID of. I cannot just change the original page meta-tags because the replacement changes based off a custom field in the page.
I've tried this, but apparently wp_head() is unaffected by the_post()...
<head>
...
<?php
if (...)
{
$meta_page = new WP_Query([ 'page_id' => $meta_page_id ]);
while ( $meta_page->have_posts() )
{
$meta_page->the_post();
wp_head();
}
wp_reset_postdata();
}
else wp_head() ?>
...
</head>
Hope it's clear enough; first question here.
Thanks in advance.
本文标签: wp queryOverwrite YoastSEO metatags with another page39s
版权声明:本文标题:wp query - Overwrite YoastSEO meta-tags with another page's 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738666073a2105707.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论