• Resolved CallMeAndy

    (@callmeandy)


    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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.

    Thread Starter CallMeAndy

    (@callmeandy)

    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.

    Thread Starter CallMeAndy

    (@callmeandy)

    Resolved

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Templates and the editor!’ is closed to new replies.