• Resolved Steven

    (@spstieng)


    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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • try to add a new line with ‘apply_filters() to the end of your code:

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

    Thread Starter Steven

    (@spstieng)

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

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_post not outputting all HTML’ is closed to new replies.