I have this code to display 4 posts of type "testimonial" on the Home page:
<?php $custom_posts = get_posts([ 'numberposts' => 4, 'post_type' => 'testimonial' ]); ?> <?php foreach ($custom_posts as $post) : setup_postdata($post); ?> <article> <?php the_excerpt(); ?> <a href="<?php the_permalink(); ?>">Continue reading</a> <p><?php echo get_post_meta($post->ID, 'pacient', TRUE); ?></p> </article> <?php endforeach; ?>
This works as expected. Excerpts are shown. Sunshine rainbows. Unfortunately if I move exactly the same code to the sidebar on other side no excerpts are shown. There is content trimmed down for each post instead.
In other words: This exact same code (copy/pasted) on home page produces excerpts. In the sidebar on other page it produces trimmed content with "[...]" at the end. I have no clue why. Can the problem be related to where the get_post function is called (after Query or something).
Why this function behaves differently in both cases? How do I force it to show excerpt only and not the post content. Am I missing something?