• Resolved artsmc

    (@artsmc)


    So Im creating a custom site that uses WordPress as a CMS. But I have just one issue. after I do a query in top of the page to spit out latest stories I also spit out the query in my if have post loop.

    <div id="slider">
    <ul>
    <?php query_posts('cat=3'); ?>
    <?php while (have_posts()) : the_post();?>
    <li>
    <h1>Latest News</h1>
    <h3><a href='<?php the_permalink(); ?>'><?php the_title(); ?></a></h3><br/>
    <p><a href='<?php the_permalink(); ?>'><?php the_excerpt(); ?><br/></a></p>
    </li<?php endwhile; ?>
    </ul></div>

    So that code works perfectly as it should problem is I want the loop not to run when I want information from my current page to display in the body and not the loop

    <div class="span-14 append-1 last" id="body-content">
    				<?php
    				getFirst_ID();
    				 ?>
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    
    				<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    					<?php if ( is_front_page() ) { ?>
    						<h2 class="entry-title"><?php the_title(); ?></h2>
    					<?php } else { ?>
    						<h1 class="entry-title"><?php the_title(); ?></h1>
    					<?php } ?>				
    
    					<div class="entry-content">
    						<?php the_content(); ?>
    						<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
    						<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
    					</div><!-- .entry-content -->
    				</div><!-- #post-## -->
    
    <?php endwhile; ?>

    That is what is in the body so here is the link to the site
    Pamelaruizassociates.com That way you can see the issue first hand.
    If you are able to help thank you very much Do note I cannot just call a page number to pull content from because this is the template for all pages and since the client is not a programmer I don’t expect them to come in and create custom pages.

Viewing 2 replies - 1 through 2 (of 2 total)
  • if you have a custom query loop, and want to get back to the original query string, try and add a wp_reset_query(); after the endif; of the custom loop.
    (in your case, not using the if(have_posts()) – add it after the endwhile; )

    Thread Starter artsmc

    (@artsmc)

    That worked your a gift from God lol.
    ohh I had that problem on both the page and the single.php
    but i was able to fix the page.php with

    <?php
      $page_id = $post->ID;
    	print("<div id='page-id' style='display:none;'>$page_id</div>");
    ?>

    Near get_header() and then added a …

    <?php
    $page = $page_id;
    query_posts("page_id= $page ");
    ?>

    just before it checks to see if there are post in that page id.

    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

    maybe that may help someone with a different kind of issue but thank you that worked perfectly

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Page template problems’ is closed to new replies.