WordPress.org

Support

Support » How-To and Troubleshooting » list all topics by name on sidebar

list all topics by name on sidebar

Viewing 11 replies - 1 through 11 (of 11 total)
  • When you say topic are refering to posts or categories?

    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

    Perhaps this tag will do the trick
    /Template_Tags/get_posts

    There’s a parameter for orderby post title

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

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

    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)

    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.

    <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.

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

    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>

    <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.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘list all topics by name on sidebar’ is closed to new replies.