zhaoJian's Tech Notes

WordPress Method to Call Page Content

Technology ~1058 words · 3 min read - views

WordPress method to call page content. Sometimes under special conditions, the original WordPress page content retrieval code doesn’t work properly. In such cases, you can’t output through WordPress’s built-in template tags, and you need to change the approach by outputting through PHP syntax.

Searched online for many solutions but couldn’t find one that worked. They were all copied content, and the replies were so pretentious. I want to express my disdain - when replying to others or telling them solutions, would it kill you to say one more sentence? Would it kill you to give an example? Would it kill you to not be pretentious? Acting like you’re so much better than everyone. I can’t stand people like that. If you know something, either don’t tell others at all, or if you do, don’t say it in fragments. So annoying.

The solution is as follows:

<?php
$page_id = 1; //The 1 here is the page ID, fill in whatever the ID number is
echo get_post($page_id)->post_content; //This line outputs the retrieved page content, no need to modify
?>
Share:

Comments