• sulcalibur

    (@sulcalibur)


    I’m having some strange things happen when I’m trying to have a list of the five latest titles from one category in the footer.

    Currently I have

    <div class="footbox2">
            		<h3 class="previousarticles">Previous Articles</h3>
    				<?php query_posts("category=7&amp;showposts=5"); ?>
    				<?php if (have_posts()) : ?>
    				<?php while (have_posts()) : the_post(); ?>
    				<ul><li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    				<?php endwhile; ?>
    				<?php else : ?>
    				<li>There are currently no news posts.</li>
    				<?php endif; ?>
    				</ul>
    				<hr />
    				<p>If you cannot see what you are looking for you can check the <a href="http://77pixels.com/archive">archives</a>, use the <a href="http://77pixels.com/search">search</a> (just to the left) or <a href="http://77pixels.com/contact">contact me</a> directly &amp; I promise I'll get back to you as soon as I can, Suleiman.
    				</p>
               </div><!-- footbox2 -->

    Now the key thing here is
    <?php query_posts("category=7&amp;showposts=5"); ?>

    I know it is meant to be..
    <?php query_posts('cat=7&amp;showposts=5'); ?>
    But whenever I do that the page just shows up as a blank white web page with no source (weird). The code I have though works showing 5 posts, but they are from ALL categories which is the problem 🙁

    So basically I want this problem to get sorted and I have no idea what to do, as all the info just tells me to put the code that makes the page vanish.

    Any help would be great, thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • t31os

    (@t31os)

    Try using a new query like so…

    <?php $pQuery = new WP_Query('category=7&amp;showposts=5'); ?>
    <?php if ($pQuery->have_posts()) : ?>
    <?php while ($pQuery->have_posts()) : $pQuery->the_post(); ?>

    NOTE: Remove the amp; from the code which is being added by the forum (bug).

    Thread Starter sulcalibur

    (@sulcalibur)

    I tried all that and a few others online I just get a blank white page after saving and refreshing.

    t31os

    (@t31os)

    Try reseting the query before or after, depending where you other queries are.

    <?php wp_reset_query();?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Weird thing happening with showing one category list’ is closed to new replies.