WordPress.org

Ready to get started?Download WordPress

Forums

Error in Displaying Post (2 posts)

  1. vinjel
    Member
    Posted 1 year ago #

    Hi!

    Im having a problem in displaying my second post on my homepage..

    First, I code this post to my homepage..

    <div>
    <?php if ( have_posts() ) : ?>
    <?php query_posts('p=18'); ?>
    <?php /* Start the Loop */ ?>
    <?php while ( have_posts() ) : the_post(); ?>
    								 <article id="post-<?php the_ID(); ?>"  role="article">
    
    <header class="article-header">
    
    <h1 class="h2"><a>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
    
     </header> <!-- end article header -->
     <section class="entry-content clearfix">
     <?php the_excerpt(); ?>
     </section> <!-- end article section -->
    </div>

    And that code successfully displayed to my homepage..
    But after I add this code..

    <div>
    <?php if ( have_posts() ) : ?>
    <?php query_posts('cat=3'); ?>
    <?php /* Start the Loop */ ?>
    <?php while ( have_posts() ) : the_post(); ?>
    
    <article id="post-<?php the_ID(); ?>"  role="article">
    <header class="article-header">
     <h1 class="h2"><a>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
    </header> <!-- end article header -->
    
     <section class="entry-content clearfix">
     <?php the_excerpt(); ?>
     </section> <!-- end article section -->
    </div>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

    I'd encountered a white screen error..

    I also try to delete the first post, after that the second post will display. I observe that everytime I add another query_post, the whitescreen error will occurred but if i left only one query_post den the post will display...

    Hope you will help me with these problem..

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    query_posts() should never be used for a secondary Loop - only to modify the main Loop. Use WP_Query for your secondary Loop.

    Additional to that, I suspect you have a parse error in the second part of your code. Try checking your site's error logs for a more specific error message. Your host should be able to help you in accessing your site's error logs.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.