WordPress.org

Support

Support » How-To and Troubleshooting » Error in Displaying Post

Error in Displaying Post

  • 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..

Viewing 1 replies (of 1 total)
  • esmi

    @esmi

    Forum Moderator

    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.

Viewing 1 replies (of 1 total)
  • The topic ‘Error in Displaying Post’ is closed to new replies.