Displaying Page Content using PHP
I’ve just started playing around with WordPress with the intention of using it as a CMS. So far it’s working great!
But now I have a question that I can’t work out on my own. Hopefully you can understand what I’m getting at, as I find this kind of thing very hard to explain!
What PHP code can I use to display page content? For example, I’ve created two new pages in WordPress called “pageone” and “pageoneside”. I’m using a custom made theme. I’ve told WordPress to view the “pageone” page on startup. All good so far!
Now, what code can I put in the “themes\themename\sidebar.php” file that will display the “pageoneside” page content in the sidebar regardless of what page WordPress is currently processing (i.e. “pageone”)?
I’m basically after something like:
Is there a PHP function somewhere within the WordPress code that retrieves page data from the database and outputs it (when given the appropriate page ID)?
I’ve tried looking through the code, but I can’t find anything on first glances.
The plan is, once I work out this, I can create a widget that displays pages in the sidebar, if those pages exists.
For example, if the current page is called “home” and another page called “homeside” exists, then the content from “homeside” will be written into the sidebar.
The theory is, if this all works, I can create a custom side panel for each page, which can be managed just like a page, because it is a page! Make sense?
It will allow me to retain all the widget functionality, but with the added bonus of been able to display whatever content I like in the side panel, depending on the page, for any page.
Please let me know if I’m making no sense at all.
Any information you can provide me would be very much appreciated!
Best Regards, Chris!
- The topic ‘Displaying Page Content using PHP’ is closed to new replies.