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.