Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter techdriver

    (@techdriver)

    Thanks alot that worked great.

    There is the code for displaying recent posts and displaying a specific “page” on a static home page

    <?php get_header();?>
    <div id=”main”>
    <div id=”content”>
    Latest News – see all
    <?php rewind_posts(); ?>
    <?php
    $recent = new WP_Query(‘cat=3&showposts=3’);
    while ( $recent->have_posts() ) : $recent->the_post();
    ?>
    <div class=”post2″ id=”post-<?php the_ID(); ?>”>

    • ” rel=”bookmark”><?php the_title(); ?> | Posted: <?php the_time(‘F j, Y’); ?>
    • </div>
      <?php endwhile; ?>

      <?php
      $mypage = new WP_Query(‘page_id=5’);
      while ( $mypage->have_posts() ) : $mypage->the_post();
      ?>

      <div class=”page” id=”post-<?php the_ID(); ?>”>
      <h2><?php the_title(); ?></h2>
      <div class=”entry”>
      <?php the_content(__(‘Continue Reading »’)); ?></div>
      </div>
      <?php endwhile; ?>

      </div>

      <?php get_sidebar();?>
      <?php get_footer();?>

      thanks again

    Thread Starter techdriver

    (@techdriver)

    Would this be loop problem?

    The first loop works fine but the second loop has an error but it does show the page.

    Can you run a second loop on the same page (static home.php)
    When I try I get an error like:
    error msg:Call to a member function on a non-object in /home.php line 21

    line21( on the second loop): while ( $page->have_posts() ) : $page->the_post();
    ?>
    Is there something I need to do to support two loops on the same page.

    Thread Starter techdriver

    (@techdriver)

    Well it works but I get this msg also

    Fatal error: Call to a member function on a non-object in /home.php on line 20

    This is what I have…I am not sure if this is the correct way to code this.

    <?php get_header();?>
    <div id=”main”>
    <div id=”content”>
    Latest News – see all

    <?php
    $recent = new WP_Query(‘cat=3&showposts=3’);
    while ( $recent->have_posts() ) : $recent->the_post();
    ?>
    <div class=”post2″ id=”post-<?php the_ID(); ?>”>

      <?php the_title(); ?>

    </div>
    <?php endwhile; ?>

    <?php
    $page = new WP_Query(‘page_id=5’);
    //this is the line where it said the error is\\ while ( $page->have_posts() ) : $page->the_post();
    ?>
    <div class=”page” id=”post-<?php the_ID(); ?>”>
    <h2><?php the_title(); ?></h2>
    </div>
    <?php endwhile; ?>
    </div>

    <?php get_sidebar();?>
    <?php get_footer();?>

    Thread Starter techdriver

    (@techdriver)

    I tryed the code above and I get this

    Parse error: syntax error, unexpected T_WHILE in
    ???

Viewing 4 replies - 1 through 4 (of 4 total)