[resolved] Static page shows posts instead of page content (5 posts)

  1. lerrie
    Posted 3 years ago #

    In my quest to find a solution in working around Custom Post Types for a Jquery slider, I found a way by applying categories to the posts which makes them differentiate from the normal posts. On my home page (http://www.fiatteger.nl.server40.firstfind.nl/fiatteger.nl/) I display 2 categories: 1. acties (in the slider) & 2. nieuws (in the left "laatste nieuws" section) I display these categories the following way:

    <?php query_posts('category_name=nieuws&showposts=3'); ?>
     <?php while (have_posts()) : the_post(); ?>
    <div class="nieuws">
    <div class="thumbnail"><?php the_post_thumbnail( 'news-thumbnail' ); ?></div>
    <div class="nieuwstitel">
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    </div> </div>
    <?php endwhile; ?>

    Same goes for the other category.

    Now the funny thing is that since I've applied these loops my regular loop on my static front page shows (under "Fiat Teger") show the full content of the last category loop ("nieuws") in stead of the content that I created for the page. If I delete the "nieuws" loop it will show the latest 3 (or 2 in this case) posts from the "acties" loop in stead of the regular page content.

    The loop that should display the normal page content (in stead of what it does now) worked before I added the category loops and is the following:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div <?php post_class() ?> id="post-<?php the_ID(); ?>">	<h3>Fiat teger</h3>
    <?php the_content('Lees meer &rarr;'); ?>
    <?php edit_post_link('Bericht aanpassen', '<p>', '</p>'); ?></div>
    <?php endwhile; endif ?>

    Now, my question is: How can I display the regular content of my page instead of the weird full content posts of the category loops?

  2. wpismypuppet
    Posted 3 years ago #

    Don't use query_posts as it changes the main loop.

    Alters Main Loop

    query_posts() is meant for altering the main loop. Once you use query_posts(), your post-related global variables and template tags will be altered. Conditional tags that are called after you call query_posts() will also be altered - this may or may not be the intended result.

    Use get_posts instead:


    Takes the same arguments as query_posts. Follow the example on that page and you should be fine.

  3. Michael
    Forum Moderator
    Posted 3 years ago #

  4. lerrie
    Posted 3 years ago #

    @wpismypuppet Works perfectly. Thanks!
    @alchymyth Thanks for the useful information!

  5. wpismypuppet
    Posted 3 years ago #

    You are welcome...

Topic Closed

This topic has been closed to new replies.

About this Topic