0

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.

2

That 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.

  • Thank you, I'm glad it was something simple. – R Reveley May 2 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.