Forums

[resolved] get_post not outputting all HTML (3 posts)

  1. spstieng
    Member
    Posted 2 years ago #

    I have the following code:

    $openingHoursPost = get_post($openingHoursID);
          $openingHours = $openingHoursPost->post_content;

    The output should be like this: (It's how I wrote my post)

    Mon-Fri
    09:00 - 20:00
    Sat
    10:00 - 18:00
    Sun
    10:00 - 16:00

    But what I get is this:

    Mon-Fri 09:00 - 20:00 Sat 10:00 - 18:00 Sun 10:00 - 16:00

    Why do I not get line breaks?

  2. alchymyth
    The Sweeper
    Posted 2 years ago #

    try to add a new line with 'apply_filters() to the end of your code:

    $openingHours = apply_filters( 'the_content' , $openingHours );

  3. spstieng
    Member
    Posted 2 years ago #

    Woho! That worked!
    Now I've learned something new.

    But why doesn't WP automatically add filters for posts?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags