WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Category have one post? show it like a single post (8 posts)

  1. Elan42.com
    Member
    Posted 3 years ago #

    Hi ...

    I have in my template some category links for categories with only one post:
    I want WP to show me directly the post as a single page, without the need to click again on the post.

    Can you help me?

  2. Elan42.com
    Member
    Posted 3 years ago #

    is it so hard ?

    should be a basic feat ...

  3. Elan42.com
    Member
    Posted 3 years ago #

    :(

  4. Luiguis
    Member
    Posted 3 years ago #

    realted http://wordpress.org/support/topic/how-to-display-the-number-of-search-results-found-redux
    and maybe:

    <?php
    $number_of_posts = $wp_query->post_count;
    if (have_posts()) :
    while (have_posts()) : the_post();
    if ($number_of_posts == 1)
    {
    header("Location: ".$get_permalink());
    }
    ...the loop...
    ?>
  5. Elan42.com
    Member
    Posted 3 years ago #

    the header() thing is a really smart thing, did never thought about it.

    I'll try and reply.

  6. Elan42.com
    Member
    Posted 3 years ago #

    header("Location: ".$get_permalink());
    was giving me a "function must be a string" php error.
    header("Location: ".get_permalink());
    is correct.

    Thank you very much, this should be inserted in a new php version, if you think about it, it's a smart feat to open a post as a single post instead of showing it inside a category in wich it's the only post.

  7. Luiguis
    Member
    Posted 3 years ago #

    Sorry for "$" bug. I'm embarrassed.

  8. Elan42.com
    Member
    Posted 3 years ago #

    lapsus ;)

    In my previous message, "new php version" was "new version (of WordPress)".

    bye

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.