Support » Fixing WordPress » Display One Post from a Category in a Page

  • Resolved goxu



    I did search and found lots of similar questions but couldn’t find exactly what I’m looking for.

    What I’d like to do is to show only one latest post from a particular category “in a page”. I mean, I have several pages corresponding to categories and I’d like to display one post with the excerpt from a choosen category in the page.

    There are bunch of plugins for archive listing but most of times those listed entires got original styles applied and hard to edit them. Some strip html tags and do not get displayed properly.

    It would be greatly appreciated if this could be done.

Viewing 1 replies (of 1 total)
  • I did it!

    I created a new template named posts.php and made it list posts by category, and included the posts.php from the wp-page templage.

    Here is the part of the new template.

    $cat_id = $_GET[cat_id]
    $num_d = $_GET[num_d]
    $param = ‘category_name=’ . $cat_id . ‘&showposts=’ . $num_d;
    <?php if (have_posts()) : ?>
    // the loop continues…

    When I use the include() from the wp-page, I added the following. I use the permalink by the way.

    $cat_id = $pagename;
    $num_d =’1′;

    The only thing I’m not satisfied with it is it’s kind of slow.

Viewing 1 replies (of 1 total)
  • The topic ‘Display One Post from a Category in a Page’ is closed to new replies.