WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Templates and the editor! (4 posts)

  1. CallMeAndy
    Member
    Posted 2 years ago #

    Its probably a simple answer - not standard or no! Or I have just missed the obvious, but is there a way to use a page template, such as a page of posts, but to precede the output of the listings with the contents of the main window in the page editor. It seems to be an eith or scenario. At the moment - maybe there is something I can add easily in the template code.

    So as for instance to put a dialogue of some kind above the list.

  2. vtxyzzy
    Member
    Posted 2 years ago #

    It is certainly possible, and not too difficult. Your template just needs to have multiple Loops.

    To start, study the Codex article on The Loop.

    For an example, look at this site. Everything down to 'A NOTE FROM OUR CLUB:' is in the Page. Everything below that is pulled in by the template.

    The first loop is modeled after Twenty Eleven:

    if (have_posts()) {
       while (have_posts()) {
          the_post();
          global $more; $more = 0;
          get_template_part('content', get_post_format());
       }
    }

    Further down in the template is a second loop for the President's Message:

    <?php $temp_query = $wp_query;  // Save the original query
    $more = 0;
    query_posts('category_name=PresidentsMsg&posts_per_page=1');
    if (!have_posts())
       echo "Sorry, no message today.<br /><br /><br />";
    while (have_posts()) : the_post();
       get_template_part('content', 'frontpage');
    endwhile;
    ?>

    That template only shows 1 post in the PresidentsMsg category, but it could just as easily have shown more. Note that there is no provision for paging here because only the one post is wanted.

  3. CallMeAndy
    Member
    Posted 2 years ago #

    Oh I see - well I will check this out properly tomorrow - thanks so much. The upper construct is exactly the sort of thing I find in Suffusions custom template and the second more in tune with their list of posts, but either way I think I get the drift.

    Your a gentleman Josh.

    Thank you so much.

  4. CallMeAndy
    Member
    Posted 2 years ago #

    Resolved

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.