I have been trying to find a way to return page information in order to create a landing page. I have done this with posts before, to create a blog reel, and would like to achieve the same overall result with pages.
The Scenario: I use a drop menu with pages created in the WordPress. Nesting the pages builds the menu.
The Goal:
I would like to get the subpages of the parent page. When a user navigates to the parent page I would like it to return links to the subpages with a part of the content of the child page. For example, I would like to display the <div>
with class header
.
A Starting Point:
$mypages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc');
foreach($mypages as $page)
{
$content = $page->post_content;
if(!$content) // Check for empty page
continue;
$content = apply_filters('the_content', $content);
?>
<h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
<div class="entry"><?php echo $content ?></div>
<?php
}
So far function returns all of the_content
for all of the children and grandchildren pages. I would like it to specifically return only 1 div with a specific class from each child page and disregard all of the grandchildren pages.
$post->ID
in theget_pages()
call, doesn't this always refer to the current page ID?<div>
with IDhdr
from each post? And then probably rename the ID, to prevent ID collisions?<div>
you want to display? Would it be acceptable if the user had to "split up" the page using the More button? This is a bit easier to search for.