WordPress.org

Ready to get started?Download WordPress

Forums

Loop in a template page (5 posts)

  1. grankan
    Member
    Posted 6 years ago #

    Hi,

    Im trying include a loop in my template page. I try it this:

    <?php
    /*
    Template Name: Mi pagina
    */
    ?>

    <?php get_header(); ?>

    <div id="content">

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <div class="entry">
    <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>

    <?php wp_link_pages(array('before' => '<p>Pages: ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

    </div>
    </div>
    <?php endwhile; endif; ?>
    <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    </div>

    <?php get_footer(); ?>

    But dont work...

    Please help me...

    Pd. Si alquien puede hacerlo en castellano le estare eternamente agradecido... saludos,

  2. MichaelH
    Member
    Posted 6 years ago #

    You are trying to include a loop to display contents from one Page?

    I will point you to Pages, Page Templates for some more info.

  3. grankan
    Member
    Posted 6 years ago #

    I have readed "Archives with Content",

    http://codex.wordpress.org/Pages#Archives_with_Content

    it's exactly to my page... but don't work...

    The post are the same that the index page..

  4. MichaelH
    Member
    Posted 6 years ago #

    What is not working?

    What is the exact name of the template file? Is that the template file you have assigned to the Page (in Manage->Pages for that Page, see the Page Template field)?

  5. grankan
    Member
    Posted 6 years ago #

    Ok...

    Inserting:
    <?php query_posts($query); ?>

    Works correctly...

    But im trying display only specific post. The post ids are in a string (1,2,3,4,etc...) where numbers are posts ids.

    $post_ids = array(1,2,3,4);
    <?php query_posts("p=$post_ids"); ?>

    Only display the first post id...

    Any idea...

    Thanks...

    Sorry but my english!!!

Topic Closed

This topic has been closed to new replies.

About this Topic