• Resolved gbennyb

    (@gbennyb)


    i am lost and probably the most professionals here don’t recognize my question as a question, but maybe you can still help me.

    I try to show results from one catehory only (cat=5) on the start home.php

    Currently i am using this code:

    <?php if (have_posts())
    {
      while (have_posts())
      {
        the_post();
        ?>
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <p><?php the_excerpt(); ?></p>
    
    <?php  }
    }
    else
    { ?>
    
    <?php } ?>

    i tried to add this:

    <?php if (have_posts())
    {
      while (have_posts())
      {
        the_post();
        query_posts('cat=5');
    ?><h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <p><?php the_excerpt(); ?></p>
    
    <?php  }
    }
    else
    { ?>
    
    <?php } ?>

    Any idea what is wrong? Obviuosly i run into a never ending loop, but i am to less PHP programmer to get this running. Sorry, but every input is welcome

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter gbennyb

    (@gbennyb)

    it is always good posting a message here, so i finally find the solution for it somewhere else.

    This fixes my issues:

    <?php $temp_query = $wp_query; ?> 
    
    <?php query_posts('category_name=MYCATEGORYNAME&showposts=5'); ?> 
    
    <?php while (have_posts()) : the_post(); ?> 
    
      <div class="post" id="post-<?php the_ID(); ?>"> 
    
        <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> 
    
        <?php the_excerpt(); ?> 
    
      </div> 
    
    <?php endwhile; ?>
    Thread Starter gbennyb

    (@gbennyb)

    This was the link to the page with the solution for me issue….

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

The topic ‘Posts from single category in home.php’ is closed to new replies.