• Resolved romann

    (@romann)


    Hello.

    I’m looking for some easy way to list all categories, subcategories, …, and their posts in unordered lists. Something like site map, I think.

    Thank you, for all responses,
    Roman

Viewing 2 replies - 1 through 2 (of 2 total)
  • Here’s one example:

    <?php
    //for each category, show 3 posts
    $cat_args=array(
    'orderby' => 'name',
    'order' => 'ASC'
    );
    $categories=get_categories($cat_args);
    foreach($categories as $category) {
    $args=array(
    'showposts' => 3,
    'category__in' => array($category->term_id),
    'caller_get_posts'=>1
    );
    $posts=get_posts($args);
    if ($posts) {
    echo '<p>Category: term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.' </p> ';
    foreach($posts as $post) {
    setup_postdata($post); ?>
    <p>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></p>
    <?php
    } // foreach($posts
    } // if ($posts
    } // foreach($categories
    ?>

    Also look at this plugin:
    https://www.ads-software.com/extend/plugins/sitemap-generator/

    Thread Starter romann

    (@romann)

    Thank you, MichaelH.

    Now will try to understand it’s functionality.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List all posts and categories’ is closed to new replies.