WordPress.org

Ready to get started?Download WordPress

Forums

list all topics by name on sidebar (12 posts)

  1. sinthetiq
    Member
    Posted 8 years ago #

    what is the command to list all the topics by name, rather than month, or archive or whatever thanks

  2. Michael Bishop

    Posted 8 years ago #

    When you say topic are refering to posts or categories?

  3. sinthetiq
    Member
    Posted 8 years ago #

    post topics. i have a site where there is only one category, and its not a blog where dates matter.. they are rather 'articles' and i would like to have the 'articles' listed on the side. is that possible

  4. Michael Bishop

    Posted 8 years ago #

    Perhaps this tag will do the trick
    /Template_Tags/get_posts

    There's a parameter for orderby post title

  5. sinthetiq
    Member
    Posted 8 years ago #

    sorry for the noob question, but how would i implement that into the sidebar.php

  6. Michael Bishop

    Posted 8 years ago #

    Use one of the examples of code that Codex page provides where (sidebar.php template I assume) you want it.
    For example, if you want the last 10:
    <?php
    $posts = get_posts('numberposts=10&orderby=post_title');
    foreach ($posts as $post) : start_wp(); ?>
    <?php the_date(); echo "<br />"; ?>
    <?php the_title(); ?>
    <?php the_excerpt(); ?>
    <?php endforeach; ?>

  7. sinthetiq
    Member
    Posted 8 years ago #

    thanks, i tried that and it shows an excerpt of the post. rather than having an excerpt, how would i be able to list only the titles, and have it limitless (i.e., all titles listed, instead of last 10)

  8. Michael Bishop

    Posted 8 years ago #

    My bad, remove the <?php the_excerpt(); ?>
    Not sure it can be limitless, but I assume you could put an arbitrary number like 1000 in there, instead of the 10.

  9. Michael Bishop

    Posted 8 years ago #

    <ul>
    <?php
    $posts = get_posts('numberposts=1000&orderby=post_title');
    foreach ($posts as $post) : start_wp(); ?>
    <?php the_date(); echo ""; ?>

    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></li>
    <?php endforeach; ?></ul>

    `
    Here, try this.

  10. sinthetiq
    Member
    Posted 8 years ago #

    great! i've done this so far and it lists the topic titles.. however, how would i go about alphabetizing them, and having it be able to click to the entry

    <?php
    $posts = get_posts('numberposts=100&orderby=post_title');
    foreach ($posts as $post) : start_wp(); ?>
    <?php the_title(); ?>
    <?php endforeach; ?>

  11. sinthetiq
    Member
    Posted 8 years ago #

    worked! just had to add the .. is there a way to alphabetize it?

    <ul>
    <?php
    $posts = get_posts('numberposts=1000&orderby=post_title');
    foreach ($posts as $post) : start_wp(); ?>

    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?></ul>

  12. Michael Bishop

    Posted 8 years ago #

    <ul>
    <?php wp_list_cats('sort_column=name&hierarchical=1&optioncount=1'); ?>
    </ul>
    </li>
    <ul>
    <?php
    $posts = get_posts('numberposts=1000&order=ASC&orderby=post_title');
    foreach ($posts as $post) : start_wp(); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></li>
    <?php endforeach; ?></ul>

    Just add the order=ASC, but for someone else looking to do this, this is the final correct code to do it.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.