• I have a custom post type called newsletters, and in the “supports” array, I have given it excerpt. The issue is that when I run a foreach loop of the newsletters on the homepage and call post.preview(20) it returns a preview of the post from the editor instead of the custom excerpt box (which is filled out).

    The problem I have is that I would like my custom excerpt, but it keeps mangling my box wrapper by inserting paragraphs all around in it, causing the box to become broken, which you can see in the link provided to my homepage (staging server on flywheel).

    If I call the excerpt on the post type itself, it works as expected. Is there a different method to obtain a custom excerpt on a different page than the post type itself? Or am I simply doing something wrong?

    Full code block:

    <div class="recent-news-cards">
      {% for recent_news in newsletters %}
        <a class="recent-news-post" href="{{ recent_news.link }}">
          <h3>{{ recent_news.title }}</h3>
          <p>{{ recent_news.preview(20) }}</p>
          <span class="primary-button--g">Read Story</span>
        </a>
      {% endfor %}
    </div>

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter shane502

    (@shane502)

    As a note, you may have to hard refresh to see the proper styles.

    Thread Starter shane502

    (@shane502)

    I have added a custom ACF block to handle this for now. If anyone can shed some light onto why it works differently when called on different posts/pages – that would be great!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post Type get_Preview renders instead of custom excerpt’ is closed to new replies.