Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Forum: Fixing WordPress
    In reply to: The Loop problems
    Thread Starter nbz

    (@nbz)

    Sorry, my mistake. I even looked at that page. Blame my stupidness.

    Forum: Fixing WordPress
    In reply to: The Loop problems
    Thread Starter nbz

    (@nbz)

    Thanks, that worked.

    It was something I really did not know. Is this documented in the Codex?

    Thread Starter nbz

    (@nbz)

    Anyone?

    Forum: Your WordPress
    In reply to: The Revival Website
    Thread Starter nbz

    (@nbz)

    Thanks.

    It is unique. I hope. It did take a long ime to design though. Trying diferent things to see what worked was frustrating. No doubt other know how it can result in forced hair loss! (well not really, but you get the idea).

    It does not have the same obvious attention to details as your site (which is also fab), but that was one of the things I wanted – something that hid the complexity.

    Thread Starter nbz

    (@nbz)

    I have found the answer!

    <?php query_posts('cat=1'); ?>

    Just before the loop, and only items from category 1 and its subcategories will display!

    Thread Starter nbz

    (@nbz)

    I have got a working version now!

    I will post a simplified version of what I have done (so as not to scare people away; in my code I have a hackish loop to divide the categories into two columns…)

    <?php$categories = array(1, 2, 3, 4,);
    foreach($categories as $categ){
    setup_postdata($post);
    $posts = get_posts('numberposts=1&category='.$categ);
    foreach($posts as $post) :
    ?>
    <div><?php the_category(', ') ?>
    <li><a href="<?php the_permalink(); ?>" title="Link to <?php the_title(); ?>"><?php the_title(); ?></a></li></div>

    <?php endforeach;
    }?>

    Thread Starter nbz

    (@nbz)

    To list 1 post from category use:

    <ul>
    <?php
    $posts =get_posts('numberposts=1&offset=1&category=4');
    foreach($posts as $post) :
    ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>

    (Read more on Codex)

    Now I just need to add something before that to search for a category, and then automatically place it in the category= bit… any ideas?

    Thread Starter nbz

    (@nbz)

    hmmm… not got any replies. I’ll guess the coe above put people off!

    What I want to do is simple really:

    1. Find all the categories.
    2. For each category find latest post.
    3. Print the category title followed by the title of the post.

    The code above (just ignore it) is the other way around: It finds latest posts and then sorts them into categories.

    I have not been able to find out how to find all categories. there is list_cats, but that just prints all categories instead of putting them in a variable to use…

Viewing 8 replies - 1 through 8 (of 8 total)