Custom post excerpts based on page ID?

I want to display the blog listing (excerpts) with data from ACF fields. There are no custom post types here. All are standard posts. I have managed to show data from ACF fields on a standard post listing (let’s say a vendors’ page).

Now, what I want to do is display a custom listing on a different page based on that page’s ID. These are the same posts, but I want to display the vendors’ discounts which are pulled from an ACF field.

I am doing this on the Salient theme. I have created a discounts page and inside it inserted a standard blog listing via Visual composer. Then I made a custom template for that page (page-discounts.php). I have tried to make a condition which will in turn make the excerpts customizable, like so:

if ( is_page( '4402' ) ) {
  if(have_posts()) : while(have_posts()) : the_post(); 
  endwhile; endif; 

I have tried to show the AFC fields via calls like this:

<?php the_field('discounts_promo'); ?>

But they just don’t show up. I managed to show custom excerpts on other pages – standard blog listings (via entry.php in Salient theme), but I can’t figure out where to put the condition which will display different excerpts based on page ID. I have tried putting this condition inside single.php and entry.php but it doesn’t work. Should it be done inside the functions.php file?

Read more here: Custom post excerpts based on page ID?

Leave a Reply

Your email address will not be published. Required fields are marked *