Only 1 of 9 child pages content is showing (WordPress & php)? why oh why

6 replies
Any help on this one would be appreciated!!

On my page Industry Executive Interviews | mosaic global executive search I have the following code (on a template called Subpage)

(I got the code from another thread in WordPress).

Start Code
=========
<?php
$pageChildren = $wpdb->get_results("
SELECT *
FROM $wpdb->posts
WHERE post_parent = ".$post->ID."
AND post_type = 'page'
ORDER BY menu_order
", 'OBJECT');

if ( $pageChildren ) :
foreach ( $pageChildren as $pageChild ) :
setup_postdata( $pageChild );
?>
<div class="entry">
<img src="<?php $values = get_post_custom_values("thumbnail"); echo $values[0]; ?>" class="left"><?php $values = get_post_custom_values("excerpt"); echo $values[0]; ?>
<p align="right"><?php print '<a href="' . get_permalink( $pageChild->ID ) . '">[more]</a>'; ?></p>
</div>
<br clear="all">
<hr class="snip" />

<?php
endforeach;
endif;
?>

=========
End Code


Which grabs all child pages and outputs some info & custom fields on a page.

And once someone clicks on the child page link [more] only the content for the first record show on the next page (the Mike Clayville one) and all the rest don't. All child pages use the same template "Page.php"... and I can't see that anything is different on each of the sub pages.

Thanks
#child #child pages #content #pages #php #showing #wordpress #wordpress page
  • Profile picture of the author dar
    There doesn't seem to be anything wrong with the code you posted (at first glance). Try unpublishing the first child page to help narrow the problem.

    If the other pages still don't work, it's a problem with them.
    If the first one always works, there's something else wrong altogether.
    {{ DiscussionBoard.errors[84021].message }}
  • Profile picture of the author Carlos-Amigos
    I found something interesting when I did temporarily turn them off..(switched to default permalinks)

    that 2 of the pages (Hilary & Deb Dutta) when clicked upon actually showed the news page instead of their own so I deleted and recreated, the pages now work when I switch to the default permalink stucture.

    Now, what I do notice is that if I choose a different template for any of the pages for some reason it still pulls from page.php and not the custom template?

    So I am now looking into if there is a bug in WP for changing templates..

    SIDE NOTE: I have "Static Page" (Settings -> Reading) selected within the admin panel so pagename = home and pagename = news

    Another notice was that when I was viewing the news page it was using the subpage template to pull its news instead of its news.php template. Now I switched back to Front Page displays - latest post then I switched it back to static home page and it now grabs the front page content.

    So something is going on with page templates.
    {{ DiscussionBoard.errors[88369].message }}
    • Profile picture of the author Carlos-Amigos
      I am happy to say that this issue has been resolved..I spend the last 5 hours messing around trying to get it to work, and then...

      I decided to re-create the pages, and reassign the template to this page, and it seems to be working, so WP must have a bug when you update templates, and I also found a bug that screws up your permalinks, as this was the other nightmare I had..I kept on wanting to go back to a previous permalink even though I had deleted that page.

      All I can say is I am glad that is now over.

      Thanks to all those who had a brief look.

      {{ DiscussionBoard.errors[89002].message }}

Trending Topics