Support » Fixing WordPress » is it possible to exclude categories using wp_get_archives ?

  • Resolved gerld

    (@gerld)


    i’m trying to add a sidebar which will only have category “3” displaying.

    can i use wp_get_archives to limite the display to category 3 ?

    i also tried using query_posts cat=’3′ but that also affects my main content for some reason. is there a way that i can use more than one query_post on a page ?

    please help

Viewing 15 replies - 1 through 15 (of 15 total)
  • i managed to exclude category 3 on my main content, and INcluded it in the sidebar,

    however, now whenever i click on a single article… i see all of them instead of the individual article (i tried adding the same query_posts exclude to the single.php page, but it still shows all articles .. except category 3 obviously)

    i have no idea why this is. any ideas?

    i’ve pretty much read through every single post with an exclude tag.. and i don’t understand why this is so difficult.

    there surely has to be a simple way to do this

    Try using get_posts():

    http://codex.wordpress.org/Template_Tags/get_posts

    It offers a category parameter you can use to limit to one category. It also avoids the headaches query_posts() can cause when it’s implemented for something beyond the default query.

    i tried getposts but it doesn’t seem to work in wp 2

    Did you try getposts() or get_posts()? The latter is the correct function name, and it works fine in WP2.

    i tried the exact code listed on codex

    <?php
    $myposts = get_posts(‘numberposts=5&offset=1&category=3’);
    foreach($myposts as $post) :
    ?>
    <?php the_content(); ?>
    <?php endforeach; ?>

    it just outputs a blank page

    How about:

    <?php
    $myposts = get_posts('numberposts=5&offset=1&category=3');
    foreach($myposts as $post) :
    setup_postdata($post);
    ?>
    <?php the_content(); ?>
    <?php endforeach; ?>

    awesome that works. thanks so much!

    I’m trying to do a similar thing, but with no success. I put the code provided by Kafkaesqui in my sidebar.php, and it gets the entire post instead of just the post title. How do I get it to just show the title of the post?

    Am I missing something?

    djen: Try using the_title() instead of the_content().

    Thanks for the quick response. That definitely pulls in the titles of the posts, but it runs them all together into one big paragraph, and none of them are showing up as links to the original posts.

    How do I make it link to the posts and put space between the titles?

    Thanks again!

    I put spaces between the titles by doing this:

    <?php the_title(‘ ‘,'<p>’); ?>

    But still no links.

    Here’s what I have:

    <?php
    $myposts = get_posts(‘numberposts=5&offset=1&category=3’);
    foreach($myposts as $post) :
    setup_postdata($post);
    ?>
    <?php the_title(‘ ‘,'<p>’); ?>
    <?php endforeach; ?>

    It puts up the title of the post, but the title doesn’t link to anything.

    Try this instead of your call to the_title():
    <p><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></p>

    Hey, that works! Thanks a million Otto42, you’re a champ!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘is it possible to exclude categories using wp_get_archives ?’ is closed to new replies.