WordPress.org

Ready to get started?Download WordPress

Forums

Custom category list with post titles (3 posts)

  1. flashpunk
    Member
    Posted 8 years ago #

    Hello,
    php noob here, looking for a little help with a category list with post titles listed under
    example:

    /category title
    / / post title
    / / post title
    / / post title
    / / post title

    /category title
    / / post title
    / / post title
    / / post title
    / / post title

    Any help would be greatly appreciated as I am completely stuck on this. Thanks!

    blockquote
    <?php
    if (is_category()):
    $cat = get_the_category();
    $cat = $cat[0];
    ?>

  2. <span class="blogroll_title">
    <?php
    foreach((get_the_category()) as $cat) {
    echo $cat->cat_name . ' ';
    } ?>
    </span>
    <ul id="first_title" class="inner-list">
    <?php $my_query = $wpdb->get_results("SELECT $wpdb->posts.* FROM $wpdb->posts, $wpdb->post2cat WHERE category_id = '$cat->cat_ID' AND ID = post_id AND post_id <> '$id' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 10"); ?>
    <?php while(list(,$my_post) = each($my_query)) : ?>
    <li id="post-<?php echo $my_post->ID; ?>"> ID); ?>" rel="bookmark" title="Permanent Link to <?php echo $my_post-> post_title; ?>"> <?php echo $my_post->post_title; ?>
  3. <?php endwhile; ?>

    <?php endif; ?>
    blockquote

  • Joshua Sigar
    Member
    Posted 8 years ago #

    Try the post below and modify it to loop all post's categories.

    http://wordpress.org/support/topic/50315?replies=22#post-276457

  • Ronny
    Member
    Posted 8 years ago #

    yes hi. i'm trying to do the same thing as the first poster. is there clearer code? i tried the code on that post but couldn't get it done.

    thanks for your time.
    Ronny

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags