WordPress.org

Ready to get started?Download WordPress

Forums

Single Category on Front Page with Introduction (6 posts)

  1. abighill
    Member
    Posted 7 years ago #

    Anybody know how to set up WordPress so that the front page displays an introduction to the site followed by the posts from a single category. Ideally I would like the introductory text to be editable from the WP Admin section via Page edit.

    I have been pulling my hair out over this one!

    Many thanks in advance if you could shed some light on this one!

  2. Chris_K
    Member
    Posted 7 years ago #

  3. abighill
    Member
    Posted 7 years ago #

    I am already using this plugin but it doesn't allow you to combine both the introduction and posts on the same page. Or am I missing something?

  4. Chris_K
    Member
    Posted 7 years ago #

    You might look for the Adhesive plugin. It allows you to make a single post "sticky" on the front page. Other posts will be below it as normal.

    or, have a look at making your own static home page. See the Creating_a_Static_Front_Page article in the codex. The "Example 3.2" might work for you. Put your static stuff at top with a mini-loop below.

  5. abighill
    Member
    Posted 7 years ago #

    Sorted. Not sure if this couldn't have been done in a more elegant more way but this seems to have solved my issue.

    ----------------------------------

    <?php
    /*
    Template Name: New Home
    */
    ?>

    <?php get_header(); ?>
    <?php get_sidebar(); ?>

    <div id="maincontent">
    <!-- Home Template -->
    <?php if (have_posts()) : while(have_posts()) : the_post(); ?>

    <div class="post">
    <h3><?php the_title(); ?></h3>
    <div class="thecontent">
    <?php the_content(''); ?>
    </div>
    </div>

    <?php endwhile; endif; ?>

    <?php query_posts('cat=1'); ?>
    <?php if (have_posts()) : while(have_posts()) : the_post(); ?>

    <?php $my_query = new WP_Query('category_name=news');
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID; ?>
    <div class="post">

    <h2><?php the_date(); ?></h2>
    <h3><a>"><?php the_title(); ?></a></h3>
    <div class="thecontent">
    <?php the_excerpt(); ?>

    </div>
    </div>
    <?php endwhile; ?>

    <?php endwhile; endif; ?>

    </div>

    </div>

    <?php get_footer(); ?>

    ----------------------------------

    1.) This template page has been named home.php.

    2.) Where there is a category with the slug 'news' and category ID = 1.

    3.) Static Page plugin is installed as suggested.

    Thanks

  6. abighill
    Member
    Posted 7 years ago #

    Correction: this is not resolved.

    See here: http://wordpress.org/support/topic/89624

    For some reason it is mulitplying the posting category by the number of posts.

Topic Closed

This topic has been closed to new replies.

About this Topic