admin管理员组文章数量:1431763
I am inserting a snippet of text into posts when posts have a certain taxonomy.
I want this text to be editable by WP users n the admin area.
The following doesn't seem to want to do anything for me, admittedly I copied pasted and amended from another thread on here.
<?php
if ( has_term( 'ART', 'product_relevance' ) ) {
?>
<div class="row">
<div class="notification col-lg-9 order-1">
<?php
$my_id = 927;
$post_id_927 = get_post($my_id, ARRAY_A);
$title = $post_id_927['post_content'];
?>
</div>
</div>
<?php
}
?>
The if statement works fine, it is just the block calling the post by ID.
I am inserting a snippet of text into posts when posts have a certain taxonomy.
I want this text to be editable by WP users n the admin area.
The following doesn't seem to want to do anything for me, admittedly I copied pasted and amended from another thread on here.
<?php
if ( has_term( 'ART', 'product_relevance' ) ) {
?>
<div class="row">
<div class="notification col-lg-9 order-1">
<?php
$my_id = 927;
$post_id_927 = get_post($my_id, ARRAY_A);
$title = $post_id_927['post_content'];
?>
</div>
</div>
<?php
}
?>
The if statement works fine, it is just the block calling the post by ID.
Share Improve this question asked May 1, 2019 at 16:22 R ReveleyR Reveley 1617 bronze badges1 Answer
Reset to default 2That code never outputs anything to the page:
<?php if(has_term('ART', 'product_relevance')):
$my_post = get_post(927);
if(isset($my_post->post_content)): ?>
<div class="row">
<div class="notification col-lg-9 order-1">
<?php echo $my_post->post_content; ?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
Untested, but in essence you need to do something with the post content.
本文标签: Inserting post content into pages when using custom taxonomies
版权声明:本文标题:Inserting post content into pages when using custom taxonomies 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745534876a2662226.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论