I have a custom loop in a page template to display posts by category by give category and tag. It works, but above the loop I need to show the content of the page itself, i.e. the content that’s been entered into the WordPress Dashboard normally.
What do I add to my template to display this content?
I have tried:
$id = $post->ID;
get_page($id);
// then my custom loop
Which does get the current page ID, but no content.
In WordPress, calling
will pull in the content from the WYSIWYG editor on the page that is using that template as long as it is inside the loop.
The most basic example of this might look like this:
More info here: http://codex.wordpress.org/Function_Reference/the_content
In my case, with a modern theme and using Gutenberg blocks, I had to apply filters to the content before the posts loop, as mentioned in this thread here: Proper way to get page content
Following one of the examples, a simple working solution would be:
To display the content of the page, using the
the_content()
function.Added your custom loop after this function call.