Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End inserting a page inside a page

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #28587
    kloy
    Member

    I need to insert 4 pages inside one page. I just saw this snippet in the Snippets section for WordPress.
    The thing is I only want this on the home page. If I put this code in the page.php file it will occur on all pages??
    I can’t use this code in the html editor for the parent page can I ?

    <?php $recent = new WP_Query("page_id=**ID**"); while($recent->have_posts()) : $recent->the_post();?>
    <h3><?php the_title(); ?></h3>
    <?php the_content(); ?>
    <?php endwhile; ?>

    Someone told me about
    <?php if (is_home()): ?>
    though I’m not too sure how to use it.

    Thanks!!

    #73306
    TheDoc
    Member

    Three pages inside a page… it sounds more like those pages should be posts, no?

    #73310
    davidandre
    Member

    Hi Kloy ,

    <?php $recent = new WP_Query("page_id=**ID**"); while($recent->have_posts()) : $recent->the_post();?>
    <h3><?php the_title(); ?></h3>
    <?php the_content(); ?>
    <?php endwhile; ?>
    this code will insert just one page:("page_id=**ID**")….

    If you want to insert pages that are child pages of the current page then this code should work:

    <?php
    $pages = get_pages(‘child_of=’.$post->ID.’&sort_column=post_title’);
    $count = 0;
    foreach($pages as $page)
    { ?>
    <h4><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h4>
    <?php
    }
    ?>

    hope it help!

    #73316
    kloy
    Member

    The Doc,
    Yes I thought that maybe I should use posts for this. I’m using primarily pages for this site.
    When I try to use a post the side bar disappears?? Though I took out the plug in that seemed to be causing lots of problems, so maybe it will work now.


    David Andre,
    Thanks for the code. I’ll try it out

    Thanks for your help guys!!!!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.