Support » Plugins and Hacks » multiple pages/post on single page

  • Resolved kvnthng

    (@kvnthng)


    right here goes…

    I am basically tring to make a single page as a sort of portal, so the home page will consist of these pages:

    1. about
    2. work
    3. blog (news)

    I have managed to display the blog and the “about” page but i can’t get the second page to show, here is what i am using in page.php (wp set to display static page):

    <?php get_header(); ?>
    
    <div class="grid_7" id="intro">
    
        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <div class="post" id="post-<?php the_ID(); ?>">
        <h2><?php the_title(); ?></h2>
        <div class="entry">
        <?php the_content('<p class="serif">Read the rest of this page &raquo;
    '); ?>
    
        <?php wp_link_pages(array('before' => '<strong>Pages:</strong> ', 'after' => '
    ', 'next_or_number' => 'number')); ?>
    
        </div>
        </div>
        <?php endwhile; endif; ?>
        <?php edit_post_link('Edit this entry.', '', '
    '); ?>
    
    </div><!--intro end-->
    
    <div class="grid_5" id="news">
    
    	<?php
        $lastposts = get_posts('numberposts=3');
        foreach($lastposts as $post) :
        setup_postdata($post);
        ?>
        <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
        <?php the_content(); ?>
        <?php endforeach; ?>
    
    </div><!--news end-->
    
    <div class="grid_7" id="contact">
    
        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <div class="post" id="post-<?php the_ID(); ?>">
        <h2><?php the_title(); ?></h2>
        <div class="entry">
        <?php the_content('<p class="serif">Read the rest of this page &raquo;
    '); ?>
    
        <?php wp_link_pages(array('before' => '<strong>Pages:</strong> ', 'after' => '
    ', 'next_or_number' => 'number')); ?>
    
        </div>
        </div>
        <?php endwhile; endif; ?>
        <?php edit_post_link('Edit this entry.', '', '
    '); ?>
    
    </div>
    
    <?php get_footer(); ?>

    you can see what i have got here (the blue div neeads to show “work” id=5):
    test site

    can anybody advise how to show these 3 items on a single page ?

    thanks in advance

    :K

Viewing 10 replies - 1 through 10 (of 10 total)
  • Wouldn’t you need to do:

    $lastposts = get_posts('page_id=x');

    where x is the id for work?

    Related:
    http://www.daobydesign.com/blog/2007/07/modifying-wordpress-front-page/

    Hi MichaelH

    i have changed the section for work to this:

    <div class="grid_7" id="work">
    
    	<?php
        $lastposts = get_posts('post_id=5');
        foreach($lastposts as $post) :
        setup_postdata($post);
        ?>
        <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
        <?php the_content(); ?>
        <?php endforeach; ?>
    
    </div><!--work end-->

    but it is showing the blog post (Post #01) and not my “work” page (id=5)

    is that what you meant?

    test site

    $lastposts = get_posts('page_id=5');

    NOT

    $lastposts = get_posts('post_id=5');

    Thanks but – ahh i give up…
    changed it and it is still showing posts instead of work page…

    <?php get_header(); ?>
    
    <div class="grid_7" id="intro">
    
        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <div class="post" id="post-<?php the_ID(); ?>">
        <h2><?php the_title(); ?></h2>
        <div class="entry">
        <?php the_content('<p class="serif">Read the rest of this page &raquo;
    '); ?>
    
        <?php wp_link_pages(array('before' => '<strong>Pages:</strong> ', 'after' => '
    ', 'next_or_number' => 'number')); ?>
    
        </div>
        </div>
        <?php endwhile; endif; ?>
        <?php edit_post_link('Edit this entry.', '', '
    '); ?>
    
    </div><!--intro end-->
    
    <div class="grid_5" id="news">
    
    	<?php
        $lastposts = get_posts('numberposts=1');
        foreach($lastposts as $post) :
        setup_postdata($post);
        ?>
        <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
        <?php the_content(); ?>
        <?php endforeach; ?>
    
    </div><!--news end-->
    
    <div class="grid_7" id="work">
    
    	<?php
        $lastposts = get_posts('page_id=5');
        foreach($lastposts as $post) :
        setup_postdata($post);
        ?>
        <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
        <?php the_content(); ?>
        <?php endforeach; ?>
    
    </div><!--work end-->
    
    <?php get_footer(); ?>

    intro is fine, news is fine but work div still shows blog posts not the work page.

    goning to put my head in the oven 🙁

    Okay start at the beginning:

    You want your main page to show:

    1. The content of the About Page
    2. The content of the Work Page
    3. The content of the News Page

    Yes

    1. The content of the About Page (static page)
    2. The content of the Work Page (static page)
    3. The content of the News Page (the blog entries)

    So instead of having 3 pages to navigate between its all on the homepage.

    I had success using the WordPress Default theme’s index.php

    I replaced:

    <div id="content" class="narrowcolumn">
    
    	<?php if (have_posts()) : ?>

    with

    <div id="content" class="narrowcolumn">
    
    	<?php
        $aboutpage = get_posts('page_id=2');
        foreach($aboutpage as $post) :
        setup_postdata($post);
        ?>
        <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
        <?php the_content(); ?>
        <?php endforeach; ?>
    
    	<?php
        $workpage = get_posts('page_id=5');
        foreach($workpage as $post) :
        setup_postdata($post);
        ?>
        <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
        <?php the_content(); ?>
        <?php endforeach; ?>
    
    	<?php if (have_posts()) : ?>

    Fantastic it works!

    *takes head out the oven*

    Thanks for your patience! 🙂

    In a Columbo style… jus one more thing…

    would this also work on sub sites on WPMU?

    Can’t say. Try it.

    thanks again 🙂

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘multiple pages/post on single page’ is closed to new replies.