WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Help] TwnetyTen Church Theme hack - How to add posts under static page (4 posts)

  1. Anuradha Edirisuriya
    Member
    Posted 3 years ago #

    Hello,
    I'm using TwentyTen child them, TwentyTen Church.
    http://wpshed.com/twenty-ten-child-theme-twentyten-church/

    I want to know how to add latest posts from a specific category under the static page. Even though I found so many methods in the forum, none of them works perfect.

    Help is much appreciated.

    Thanks in advance.

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    You probably need to add a custom query to your theme's front page template file (either index.php or front-page.php).

    http://codex.wordpress.org/Function_Reference/query_posts
    http://codex.wordpress.org/Function_Reference/WP_Query

  3. Anuradha Edirisuriya
    Member
    Posted 3 years ago #

    Thank you for the reply. I'm a newbie in php functions. :(
    Can you help me to find the exact code that would do the job?

    Below is an example of what exactly I want. It is edited with photoshop.

    http://i.imgur.com/Tuax2.jpg

    Regards,
    Anuradha.

  4. Anuradha Edirisuriya
    Member
    Posted 3 years ago #

    I was able to do it successfully with

    <div id="content">
    <div class="post">
    
    <h3>Recent Articles</h3>
    
    <?php $posts = get_posts( "category=X&numberposts=5" ); ?>
    <?php if( $posts ) : ?>
    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    <div class="post">
    <h2><a href="<?php echo get_permalink($post->ID); ?>" ><?php echo $post->post_title; ?></a></h2>
    <?php the_excerpt(); ?>
    
    </div>
    <?php endforeach; ?>
    <?php endif; ?>
    
    </div>

    this code. But whenever I go to another page, the recent news appear on other pages too. The function, is_home() is also not working. Please help me to solve the issue.

    Sorry, I couldn't mention my website earlier.
    http://prefects.bandaranayakecollege.org

    Thank you.
    Anuradha.

Topic Closed

This topic has been closed to new replies.

About this Topic