WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp_list_categories to show only 1 post (10 posts)

  1. sirhank
    Member
    Posted 5 years ago #

    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?

  2. MichaelH
    Member
    Posted 5 years ago #

    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);
    ?>

  3. sirhank
    Member
    Posted 5 years ago #

    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

  4. MichaelH
    Member
    Posted 5 years ago #

    Oops it should be

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

  5. sirhank
    Member
    Posted 5 years ago #

    Many thanks MichaelH this works great!

    your a star :)

  6. sirhank
    Member
    Posted 5 years ago #

    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

  7. sirhank
    Member
    Posted 5 years ago #

    All sorted now - thanks for your help :)

  8. Pali Madra
    Member
    Posted 4 years ago #

    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

  9. MichaelH
    Member
    Posted 4 years ago #

    palimadra - please start another topic with that question.

  10. Pali Madra
    Member
    Posted 4 years ago #

    Thanks Micheal,

    I will do that.

    Regards,
    Pali Madra

Topic Closed

This topic has been closed to new replies.

About this Topic