Support » Fixing WordPress » Want display 5 post from each taxonomy in page template

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Diana K. Cury

    (@dianakc)

    The code below is almost working. This code works for showing 5 last posts from all categories, I adapted to show post_types, but it shows the same posts.

    categoria = taxonomy
    anuncios = post_type

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Also, I want to add the RSS for every taxonomy, the code I have works nice, but only in single template (a bit hard-coded):

    <p><?php echo get_the_term_list( get_the_ID(), 'categoria', "In: " ) ?> <a href="<?php bloginfo('url') ?>/?feed=rss2&categoria=<?php $terms_as_text = strip_tags( get_the_term_list( $wp_query->post->ID, 'categoria', '', ', ', '' ) );
    echo $terms_as_text; ?>" >RSS</a> </p>

    Just need to insert the code above beside every taxonomy title and show the correct posts. Almost there, but I need some help!

    Thread Starter Diana K. Cury

    (@dianakc)

    Sorry.

    The code I’m using, is supposed to display 5 posts from each taxonomy, but is not working, is showing the same posts everytime:

    Code in Pastebin

    I think you need to add the category id to your get_posts arguments:

    $post_args = array(
      'post_type' => 'anuncios',
      'cat' => $category->term_id
    
        );
    Thread Starter Diana K. Cury

    (@dianakc)

    Thanks vtxyzzy, but still don’t work!

    When added 'cat' => $category->term_id, nothing shows up.

    Echo out $category->term_id to see if it has the category id in it.

    Thread Starter Diana K. Cury

    (@dianakc)

    Thanks, vtxyzzy I just found a new code and works fine:

    List posts from taxonomies

    The code above is quite simples but only for returning posts from categories.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Want display 5 post from each taxonomy in page template’ is closed to new replies.