WordPress.org

Ready to get started?Download WordPress

Forums

Menu listing all posts in current category (8 posts)

  1. Kerim
    Member
    Posted 10 years ago #

    I'd like the menu to have a section that dynamically displayed links to all (or up to a certain number) the posts in a given category. So, if I am in category "books" and I have 10 posts on 10 different books, there will be a menu that says:
    Contents
    -Book1
    -Book2
    -Book3
    ...etc.
    With the titles of the posts for each book.
    Thanks.

  2. Kerim
    Member
    Posted 10 years ago #

    Just to explain further. I need a snippit of code that will:
    (1) figure out what the current category is.
    (2) Display a list of all posts in that category, as a menu with links to the name of the posts.
    I really need to be able to do this in order for WP to work for the site I am planning, but I don't know how to go about this. Any suggestions would be greatly appreciated!

  3. Kerim
    Member
    Posted 10 years ago #

    OK, from this wiki page:
    http://wiki.wordpress.org/index.php/PostsByCategory
    I was able to get a start. However, I'm still running into trouble.
    Here is what I have:
    <?php
    $cat="5";
    $blog=1;
    require_once("wp-blog-header.php");
    foreach ($posts as $post) { start_wp(); //start of loop
    echo "<br/> " . the_title() . "";
    } //end of loop
    ?>
    This has two problems.
    (1) It doesn't produce the right code. For some reason, the "title" appears before the start of the URL, rather than inbetween the href = tag and the closing tag like I would think it should. I have no idea why this is happening.
    (2) I still have to manually specify the category. I would like it to be able to know the category of the current post.
    Thanks!

  4. Kerim
    Member
    Posted 10 years ago #

    This is ugly, but it works:

    <?php
    $cat=get_category_names();
    $blog=1;
    require_once("wp-blog-header.php");
    foreach ($posts as $post) { start_wp(); //start of loop
    ?>

  5. " rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?>
    <?
    } //end of loop
    ?>

    It requires this hack:
    http://wordpress.org/support/3/1621#post-4

  • Kerim
    Member
    Posted 10 years ago #

    This is ugly, but it works:
    <?php
    $cat=get_category_names();
    $blog=1;
    require_once("wp-blog-header.php");
    foreach ($posts as $post) { start_wp(); //start of loop
    ?>

  • " rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?>
    <?
    } //end of loop
    ?>
    It requires this hack:
    http://wordpress.org/support/3/1621#post-4

  • Kerim
    Member
    Posted 10 years ago #

    [Sorry, I discovered that the "code" tags don't work in these forums. I found the "escape HTML entitites" page however. Hopefully this will work!]
    This is ugly, but it works:
    <?php
    $cat=get_category_names();
    $blog=1;
    require_once("wp-blog-header.php");
    foreach ($posts as $post) { start_wp(); //start of loop
    ?>

  • " rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?>
    <?
    } //end of loop
    ?>
    It requires this hack:
    http://wordpress.org/support/3/1621#post-4

  • Kerim
    Member
    Posted 10 years ago #

    Arghh!
    It turns out that this hack doesn't work at all. If you click on a "category" link it does show all posts in the category, but if you click on the permalink to an individual post it only shows that post, not the other ones in the same category!
    HELP! (please)

  • sithicus
    Member
    Posted 8 years ago #

    Luhman,

    I'm sure you have solved this by now, but I think when you clikc on the permilink it's bringing you to a different page in the template therefor you need to create a new menu... for that page.

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags

    No tags yet.