• I’ve working on a template for pages. This template should contain a loop which lists only posts.
    But the loop gives pages back but no posts.
    Any ideas

    Example code:
    <?php rewind_posts(); ?>
    <?php // query_posts(‘category_name=filmtip&showposts=6’); ?>

      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    • <?php the_title(); ?>
      <?php the_time(‘d.m.Y’,display); ?> “>mehr
    • <?php endwhile; else: ?>

    • <?php _e(‘Keine aktuellen Meldungen’); ?>
    • <?php endif; ?>

Viewing 10 replies - 1 through 10 (of 10 total)
  • Uncomment (that is, remove the // before) query_posts:

    <?php query_posts('category_name=filmtip&showposts=6'); ?>

    Thread Starter suedkind

    (@suedkind)

    well this would result in displaying only posts of this category

    don’t you need <?php the_content(); ?>
    inside the loop?

    Thread Starter suedkind

    (@suedkind)

    not in this case, the loop should only display the titles of the posts

    Am I right thinking you’d like to have a kind of “archived” list of the posts? If so, take a look at Clean Archives, it does exactly that.

    Or remove the ‘category_name’ portion of your query_posts:

    <?php query_posts('showposts=6'); ?>

    Change the showposts # for lessening/increasing the number of posts displayed.

    Thread Starter suedkind

    (@suedkind)

    @moshu
    no, i would like to display the most current posts

    @kafkaesqui
    that’s it, thank you very much

    Oooo. Oooo. I think this may actually be what I’m trying to do… I’m using a theme (modified K2) which creates cool tabs across top of the home page, with the name of each Page I’ve created using Create Page.

    When you click on the tab, it goes to the page with the static content of that page. Obviously. However, I want some of these Pages to have posts that correspond to the posts in a Category of the same name as the post.

    (Clicking on the “News” tab – Page – would show some static content AND underneath the static content show the posts in the “News” Category.)

    Any help would sure be appreciated!

    I need it to work this way because of the theme and some of the other plug-ins I’m using, such as Sidebar Modules.)

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    duckster: Make a new page template (using a copy of your existing one as a base to work from) and then do pretty much just what he did above. Put a loop in the page template. Then make a page using that template.

    OK… that’s easier said than done for me, I think. My theme has a loop.php, and in the index.template, it says,
    <?php get_header(); ?>

    <div class=”content”>

    <div id=”primary”>

    <?php include (TEMPLATEPATH . ‘/theloop.php’); ?>

    </div>

    <?php get_sidebar(); ?>

    </div>

    <?php get_footer(); ?>

    What am I supposed to do here?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Loop for posts in pages’ is closed to new replies.