Support » Themes and Templates » New Posts – Display From Specific Category

Viewing 7 replies - 1 through 7 (of 7 total)
  • query_posts(‘category_name=Staff Home’);

    or you can use the ID.

    Thanks for trying to help, I appreciate the effort, but that’s not enough information.

    Here is a sample page.

    You will see in the sidebar their are 2 sections. I need to be able to have posts from their respective categories to appear.

    I tried this:

    <?php query_posts("category_id=6&orderby=desc&showposts=4"); ?>
    <?php while (have_posts()) : the_post(); ?>
    <li><?php the_time('F j, Y'); ?><br /><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>

    It made the actual page content wonky. It is displaying a post rather then the page content.

    First. You can call the category by cat=6 rather than category_id=6.

    If you are doing additional queries beyond the main loop on the page then you can use this:

    $latestPosts = new WP_Query();
    while ($latestPosts->have_posts()) : $latestPosts->the_post();
    ?> your li display thing here...
    <?php endwhile; ?>

    …and then a second time for the next loop.

    You, my dear, are brilliant! Assistance on these forums is usually non-existent, so your help is much appreciated! I’m definitely no PHP expert. 😉

    Your welcome. I “wish” I was brilliant!

    What about links?

    Tried this and was unsuccessful:

    				$bookmarks = new WP_Query();
    				$bookmarks = get_bookmarks("cat=15");
    				if ($bookmarks[0] != '') { ?>
    				foreach ( $bookmarks as $bookmark ) {
    			<li><a href="<?php echo clean_url($bookmark->link_url); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>" target="_blank"><?php echo $bookmark->link_name; ?></a></li>
    			<?php endwhile; ?>

    Nevermind! Got it worked out! 🙂

    Looks like there’s a mistake in codex.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘New Posts – Display From Specific Category’ is closed to new replies.