Using Pages to Hold Content for a Wordpress Template Page
I have been using pages to hold content in Wordpress templates for some time now. The problem I have with it is that every time I need to perform such an action I cannot remember how to do it nor where I have done it before. I did find one of the examples I have used before but there was one catch. The content had new lines in it for breaks and the content was not displaying correctly on the page. Wordpress saves its pages in the database without <br/> tags. So, I did a a little research and this is what I found:
<?php
$n = 217;
$p = get_page($n); // variable is passed by reference
print apply_filters('the_content', $p->post_content);
?>
We are getting a page by id and using the get_page() function to retreive the content of that page. The id needs to be assigned to a variable because the function expects a variable to reference. Now, the key to get your content to display the way you want it to is the apply_filters() function. The filter we are going to use is the the_content filter. This is the same filter used by the the_content() function that is used in your template files.
