• Hi, I am trying to get the title of the five most recent posts with the number of comments in my footer. I don’t want to use the widget. What is the code to do this.
    I have tired
    <?php query_posts(‘showposts=5&orderby=date’); ?>
    But nothing shows up

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • To run php code in pages, posts, and text widgets you need to use a plugin like Exec-Php

    https://www.ads-software.com/extend/plugins/exec-php/

    revilo999

    (@revilo999)

    I am also trying to use the recent posts but by adding them to my home page outside wordpress then when visitors click on ant post it takes them to the wordpress articles. Any help would be appreciated.

    @ revilo999: I don’t believe you can call a WordPress function outside of the loop. Try utilizing a feed reader to accomplish this.

    @uteman23: Try using this code to call the top most recent headlines

    <?php
        $recent_posts = new WP_Query();
        $recent_posts->query('showposts=5');
    ?>
    <?php while ($recent_posts->have_posts()) : $recent_posts->the_post(); ?>
        <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
    <?php endwhile; ?>

    This should pull the title for you. You can also pull the excerpt if you’d like by using adding this code:
    <?php the_excerpt(); ?>

    Style however you’d like.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Recent Posts’ is closed to new replies.