Support » Fixing WordPress » Posts page include other content – How?

  • Rather than having a page display only my posts, I would like to create a page with content in the header area, and then have the posts list underneath it. How can this be done?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Assuming the content you would like displayed in the header is page or post content, you can create a custom wordpress query in the header file to get a specific or series of posts/pages content and then use the regular loop in the template file to get the list a normal posts.

    Here’s an example of a custom query:

    <ul class="header-posts">
        $header_query = new WP_Query("cat=42&showposts=10");
        $wp_query->in_the_loop = true;
        while ($header_query->have_posts()) : $header_query->the_post();
            <li id="header-post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
        <?php endwhile; ?>

    the above code will get 10 posts from category 42

    Thanks, that’s not quite what I’m after but may prove useful anyway.

    What I’m wondering is how to add content to the default posts page. I want to have some text and perhaps a bit of php code above the posts.

    I created a page called “News” and added content to it. Then I went to the WordPress options and set the default posts page to “News”. Now the news page content does not show up. I only see posts.

    If you want to add text and or php to the default file which displays posts, change back the “Front page displays” to “your latest posts”.

    Then open:

    index.php – displays your newest posts on the frontpage
    single.php – displays a single post entry
    archive.php – displays posts from a specific category or tag

    You can edit these files however you see fit, simply find the section of these files that says:

    <?php if (have_posts()) : ?>

    and add your text or code in an appropriate container above this code. In the default wordpress template that would look like this:

    <div id="content" class="narrowcolumn">
            The text you want to add.
        <?php if (have_posts()) : ?>

    If that’s not what your looking for, toss up a link to your site or a screen shot with what you are looking to do.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Posts page include other content – How?’ is closed to new replies.