WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] multiple pages/post on single page (11 posts)

  1. kvnthng
    Member
    Posted 5 years ago #

    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

  2. MichaelH
    Member
    Posted 5 years ago #

    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/

  3. kvnthng
    Member
    Posted 5 years ago #

    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

  4. MichaelH
    Member
    Posted 5 years ago #

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

    NOT

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

  5. kvnthng
    Member
    Posted 5 years ago #

    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 :(

  6. MichaelH
    Member
    Posted 5 years ago #

    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

  7. kvnthng
    Member
    Posted 5 years ago #

    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.

  8. MichaelH
    Member
    Posted 5 years ago #

    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()) : ?>
  9. kvnthng
    Member
    Posted 5 years ago #

    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?

  10. MichaelH
    Member
    Posted 5 years ago #

    Can't say. Try it.

  11. kvnthng
    Member
    Posted 5 years ago #

    thanks again :)

Topic Closed

This topic has been closed to new replies.

About this Topic