The content not wrapped in paragraph tags with get_page_by_title()

I am using $page = get_page_by_title('name') ; to get the contents of a page. When I echo $page->post_content; none of the content is wrapped in p tags like it is when run threw the normal wordpress loop using the_content( ). Is there a different way I should get this data so it will contain the proper tags?

Solutions

You can apply the content filters to $page->post_content like so:

echo apply_filters('the_content', $page->post_content);

Similar questions

What is an alternative to get_page_by_title()?
I'm coding a theme where I want to display information in the footer that's only available on a template page. I have been using get_page_by_title() which works well if you know what the page will be called, but in my opinion it's not very dynamic, it's impossible to predict what a user will name a page in your theme. In my research I found a funct...
get_page_by_title with an apostrophe in variable
I'm having some trouble creating a shortcode that queries some posts. This is the basics of my code: Now, ordinarily, this works fine for 99% of my posts. It queries the post by what's written inside the [item]title goes here[/item] shortcode and then displays a custom tooltip/hover effect accordingly. However, if my post title has an apostrophe in...
Combine get_page_by_title to exclude pages from wp_list_pages
I am using get_page_by_title to exclude a few pages from wp_list_pages, my code looks like: This code works, but I was wondering if there was any way to combine it so that it could be shorter - something like: This didn't work, but figured it's pretty close...just thinking the code could be simplified a bit. Any ideas? Thanks, Josh
How to search CPTs in draft using get_page_by_title()
I'm aware that get_page_by_title() is not an option when you want to look for posts (or CPTs in my case) that are not published (i.e. in draft). Some of the solutions that I've found are based on SQL queries, but they are old examples (more than 5 years old), and I'm afraid that they are not recommended according to the best practices on SQL querie...
get_page_by_title in Wordpress. How to use to fetch posts?
Recently, Wordpress added in the Trac that you can fetch posts by title using: get_page_by_title Instead of querying the database straight up. If I wanted to get post titled "my farm", how would I change the parameters so it is searching for a post (or a post type?): $page_title='Joey in the forest'; 'character' is a post type. But don't know how t...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy .