Page 1 of 1

Grabbing a page from WordPress

Posted: Sat Dec 13, 2008 9:41 am
by volomike
Has anyone used WordPress, hidden a page from the menus at the top, and then reimplemented it as like a Sidebar gadget? That way, a reverend at a church, for instance, can just click Manage Pages, grab Sidebar, edit it, and the Sidebar gadget is implemented with new text.

Here's why I ask. I'm running it down to the wire here, working on one very hard project (that has nothing to do with WordPress). However, at the same time, I needed to get some tax write-offs before Dec 31. I'm trying to do very minimal effort here with WordPress to donate some sites to churches. My wife is then jumping in to flesh the rest of the site out. We'll then fork this site like 3 times, change the look a little, and poof, 3 churches done and 3 tax write-offs.

So far we eliminated features in WordPress that the pastors could mess up accidentally, leaving only Pages, Manage Pages, a plugin called PageMash (which we renamed to Page Order), and Media Library. What I was hoping was that I could add some pages that don't show up and are instead re-implemented as content on various pages.

And if the pastor eliminated Sidebar by accident, all he would have to do is create another page titled Sidebar again, put content in, and poof, Sidebar would re-appear again because the code would look for the page named Sidebar.

Re: Grabbing a page from WordPress

Posted: Sun Dec 14, 2008 3:37 am
by greyhoundcode
Not sure this is exactly what you're after but if, for example, you have four pages:

1. About us
2. Find us
3. Giraffes
4. Fresh eggs

And you deliberately wish to exclude the Giraffes page from being part of the page navigation, you can exclude it like so:

Code: Select all

wp_list_pages('sort_column=menu_order&exclude=3&title_li=');
You can retrieve it on the page where you want to drop it in with a wp_query.

Re: Grabbing a page from WordPress

Posted: Sun Dec 14, 2008 10:55 am
by volomike
greyhoundcode wrote:Not sure this is exactly what you're after but if
Greyhoundcode! You made my day! I probably could have figured this out on my own, given enough time, but time is not what I have a lot of. It was nice to see someone with the knowledge share it and save me some time so that I can lower my taxes as well as as help some area churches here.

Re: Grabbing a page from WordPress

Posted: Fri Dec 26, 2008 2:17 am
by volomike
The way I ultimately ending up doing this was to edit wp-includes/post-template.php. I found the function "the_content()". I added a 'require_once("adjust.php") inside it so that I could play with the $content variable.

Inside adjust.php, I could do something like this:

Code: Select all

<?php
 
$sTitle = get_the_title(get_the_ID());
if ($sTitle == 'Home') {
  $oPage = get_page_by_title('Pastor-Words');
  $content = str_ireplace('{pastor-words}','<div id="pastor-words">' . $oPage->post_content . '</div>', $content);
}
I also played with $content to add in some CSS style tags so that I could style my custom DIVs.

Therefore, now I just create some unpublished pages in WordPress, and then put a {block} inside the place where I want it. For instance, on the Home page, I added in {pastor-words} in the text of the page. I then created an unpublished page called Pastor-Words. This meant that Pastor-Words was not a page tab, which was important. So, when the routine ran, it swapped {pastor-words} with the content from the unpublished page of Pastor-Words, and then styled it with the CSS that I wanted.