Wordpress and Webdesign Forum go41 » WordPress Code Snippets

  1. adamwork
    Member

    Can anyone advise the code I need, to have a page, that appears with the title of each category, and then list the posts contained withing the category, then another category with it's post etc..

    So it looks a bit like this...

    TITLE OF CATEGORY A

    POST 1 CATEGORY A
    POST 2 CATEGORY A

    TITLE OF CATEGORY B

    POST 1 CATEGORY B
    POST 2 CATEGORY B

    ETC ETC...

    Can you advise on how to setup the loop for this? This is my current code - I think I just need to add the Category tag here some where, but I'm a bit stuck...

    '<?php if (have_posts()) : ?>
    <?php query_posts('showposts=20&cat=4,3'); $i = 1; ?>

    <?php while (have_posts()) : the_post(); ?>

    <!--" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>
    <small><?php the_time('F jS, Y') ?> </small>
    -->
    <h2><?php the_time('F Y') ?></h2>
    <div class="mainNewsBlock">

    <?php $values = get_post_custom_values("Image");
    if (isset($values[0])) { ?>
    " rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=35&h=35&zc=1&q=35"
    alt="<?php the_title(); ?>" class="left" width="35px" height="35px" />
    <?php } ?>
    " rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?><?php the_excerpt(); ?>

    </div>
    <?php endwhile; ?>

    <div class="navigation">
    <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
    <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
    </div>

    <?php else : ?>

    <h2 class="center">Not Found</h2>
    <p class="center">Sorry, but you are looking for something that isn't here.</p>
    <?php get_search_form(); ?>

    <?php endif; ?>

    '

    many thanks

    Posted 1 year ago #
  2. adamwork
    Member

    Actually - I solved it using this code here: http://forum.go41.de/topic/list-selected-categories-with-3-latest-posts-each

    Many thanks :-)

    Posted 1 year ago #
  3. adamwork
    Member

    Just a thought - is there any way to set the name of the category NOT to display, if there aren't any posts?

    Posted 1 year ago #
  4. the code you refer to is actually made for the category bar of arthemia, 5 categories and if there are posts a list of 3 of them

    If you do not want to display the category title if there are no posts - what is the empty category for? You also do not need to include an empty category in the array.

    Also, listing many categories with many posts will give you a long page. Pagination will not work too.

    Is it an archive page with a list of categories and the posts in there?
    Here is some good code:
    http://blogsessive.com/blogging-tools/latest-posts-by-category-archive/

    Posted 1 year ago #
  5. adamwork
    Member

    nice, thanks joern

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Join us! or log in (lost password?):