WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] wp_list_categories to show only 1 post

[Resolved] wp_list_categories to show only 1 post

  • On my website Nicks World I am using wp_list_categories(‘orderby=name&title_li=&exclude=1,25’) for the menu in the left sidebar
    This works great but when I click on a link it displays all the posts for that link eg if I click on computers/computer software/Password Managers it displays both the posts I have in there so far (Remember My Password + Roboform Password Manager) – I would like it to display only 1 post

    Can anyone help please?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Not sure what code you are using in the template that is displaying those posts, but will at least present this:

    <?php
    $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    query_posts($query_string&showposts=’1&paged=’ . $paged);
    ?>

    Many thanks for your prompt reply

    I think I have put your code in the right place:

    <?php
    $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    query_posts($query_string&showposts=’1&paged=’ . $paged);
    ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <h1>” rel=”bookmark”><?php the_title(); ?></h1>

    Unfortunately I get this error message:
    Parse error: syntax error, unexpected ‘=’ in ******\archive.php on line 14

    Line 14 is this one:
    query_posts($query_string&showposts=’1&paged=’ . $paged);

    Any ideas how to correct this please?

    Thanks for your help

    Oops it should be

    query_posts($query_string . ‘&showposts=1&paged=’ . $paged);

    Many thanks MichaelH this works great!

    your a star 🙂

    I have now made this code ‘live’ on my website (I was testing it on my local server first before I made it live) and I have noticed 1 annoying thing …

    If you go to This page you will see a “Next Page >” link … is there any way I can stop this coming up? It only happens when there are more than 1 post in the corresponding category and clicking it does not show the next post …

    Thanks for your help

    All sorted now – thanks for your help 🙂

    In my blog I have one post in each category.

    I’m showing the categories in a menu by using
    <?php wp_list_categories(‘title_li=’); ?>

    However, the link that is created is to the category page which shows part of the one and only post.

    How can I show the full post?

    Thanks in advance.

    Pali

    palimadra – please start another topic with that question.

    Thanks Micheal,

    I will do that.

    Regards,
    Pali Madra

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] wp_list_categories to show only 1 post’ is closed to new replies.
Skip to toolbar