Support » Themes and Templates » How to embed a page into the main index?

  • Resolved Vadi



    I’d like to embed a wordpess page into the main index page of wordpress, such that the page appears first and then the latest posts appear after it. I found the command for embedding a page to be <?php query_posts('pagename=about');?></div> (with the “about” page being the one I want to embed). However no matter what I try, if I get the embedded page to show, then none of the posts will show.

    Can anyone help out please? Where is the proper place to add the code to?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Try this above the posts code (outside the loop)

    <?php $recent = new WP_Query("page_id=2"); while($recent->have_posts()) : $recent->the_post();?>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_content(); ?>
    <?php endwhile; ?>

    This will show the page with ID 2. Change this number 2 to whatever page you want to display.

    Great, thanks! It worked perfectly (

    Sorry to bother again, but while this works in a template, it doesn’t work as html in a page.

    The php code gets cutoff and shown half-way… any way to fix that? I already disabled the visual editor.

    PHP is not executed on a html file.

    I see. Just literally copying the page contents is the only way to “embed” a page?

    Let’s get back to the basics.

    What do you call “a page”?

    Furthermore, any PHP code is executed ONLY in templates, never in the content of a post or Page (aka when writing a post or Page in the WP admin panel). Nobody ever said that it would happen.

    You said you wanted to include/embed a page (Page?) into your main index. index = a template file. You got the solution.

    So, I don’t understand what is the issue now.

    Ah sorry. Now my case changed, I’d like to embed a page inside another page.

    I have several pages that are children of a page, such that they appear as links in the sidebar. However, I’d like to have all of them in the parent page also.

    For that (i.e. showing subPages on a parent Page) there should be some custom code. Try to search. And always read the docs before posting:
    (and use capital P for Pages so we know you know what you are talking about)

    If you change your mind again – here is a plugin for posts and Pages alike:

    This was exactly the solution I was looking for, so thanks a million!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to embed a page into the main index?’ is closed to new replies.