Forums

[resolved] Page Template Not Displaying Specific Category Post Problem (14 posts)

  1. digitalmikey
    Member
    Posted 7 months ago #

    Hello all, I am trying to get my downloads template to display all posts that are in the downloads category correctly. For some reason I can't get it to work at all and have become stumped completely. Below is my template code:

    <?php
    /*
    Template Name: Downloads
    */
    ?>
    
    <?php get_header(); ?>
    
    	<div id="wrapper"><a name="top"></a>
    <div id="mid" class="fix">
    	<div id="mainCol" class="fix"><a name="main"></a>
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<div id="pageMain">
    
    			<div id="download">
    <h1><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
    </div>
    
    				<div class="post" id="post-<?php the_ID(); ?>">
    
    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    
    </div>
    </div>
    
    <?php endwhile; ?>
    	<div class="navigation">
    	<?php posts_nav_link(); ?>
    </div>
    <?php endif; ?>
    
    </div>
    
    <?php get_sidebar(); ?>
    </div>
    <?php get_footer(); ?>

    I have my page header <h1> and right below that I would just like the title of each post in the "downloads" category. For some reason I can only get it to either display ALL blog posts or just a blank page. Any help will be greatly appreciated.

    [moderated--mutiple bumps removed. Please, please, please, refrain from bumping as per Forum Rules]

  2. brainycat
    Member
    Posted 7 months ago #

    Less bump. More google. Try get_category_link()

  3. digitalmikey
    Member
    Posted 7 months ago #

    Was that hard? lol

  4. digitalmikey
    Member
    Posted 7 months ago #

    Actually I don't see anything that has to do with get_category_link() to help with my problem...

    Can I get a more in depth response please or ATLEAST tell me somewhere that can...

  5. brainycat
    Member
    Posted 7 months ago #

    I'm not able to follow your problem description. As near as I can tell, this might have your answer:
    http://www.google.com/search?q=wordpress+list+posts+in+category&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

  6. digitalmikey
    Member
    Posted 7 months ago #

    No, basically I want to show posts only from ONE category in a TEMPLATE I made. Simple as that.

    The above code is my template. I need it to display just the title and permalink of each post that is in ONE category.

  7. MichaelH
    moderator
    Posted 7 months ago #

    Also review Template Hierarchy and Category Templates<--especially since, with WordPress, you don't even need a specifically coded template to display posts in a category.

  8. digitalmikey
    Member
    Posted 7 months ago #

    Is there not a simple code I could add to just show the posts from a certain category?

  9. MichaelH
    moderator
    Posted 7 months ago #

    Is there not a simple code I could add to just show the posts from a certain category?

    Where do you want to add the posts?

    But here's something:

    $posts=get_posts('cat=25');
    if ($posts) {
    foreach($posts as $post) {
    setup_postdata($post);
    ?>
    <p><?php the_time('m.d.y') ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
    <?php the_content(); ?>
    <?php }
    }
    ?>
  10. digitalmikey
    Member
    Posted 7 months ago #

    I'd like to add them in div 'pageMain' but for some reason when I add your code it makes my whole screen go white.

  11. digitalmikey
    Member
    Posted 7 months ago #

    Any suggestions Michael or whomever?

  12. digitalmikey
    Member
    Posted 7 months ago #

    Help please?

  13. Zovar
    Member
    Posted 6 months ago #

    Looks like you have to add certain parameters to The Loop.

    If you add query_posts("cat=3"); before if (have_posts()) (+replace '3' with Downloads category ID) it should work fine.

    Or you can use query_posts("category_name=Downloads");

  14. weareclouds
    Member
    Posted 4 months ago #

    Why don't you just rename the file category-downloads.php ? When you do that it will automagically do all the work you're asking it to do. It's the whole hierarchy ordeal.

Reply

You must log in to post.

About this Topic