Forums

Category posts to page using custom page template (7 posts)

  1. AardvarkGirl
    Member
    Posted 1 year ago #

    I've been working on this in earnest for 3 days now.

    What I've come up with so far is I created a page (and thus it is in the menu, perma-link ) and am using a custom page template ( category-k9forsale.php using the code that category.php uses) and gave the page the permalink 'k9forsale'.

    I have a category called 'k9forsale'. I've created 2 posts and assigned them to this category.

    I have tried following these;
    http://wordpress.org/support/topic/custom-category-page-4?replies=6
    http://codex.wordpress.org/Pages#A_Page_of_Posts
    http://codex.wordpress.org/Conditional_Tags

    Help. :-(

    All I'm getting at this point is a page that states the page title but with no posts showing up. Oh, and I'd love for the comment form to be gone from this page of category posts as well.

    I promise I'll pay it forward...

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    i don't think that a category template will keep its 'query' when used as a page template;

    if used as a page template, you might need to add a custom query before the loop.

    and simply remove / or don't add any 'comments_template()' code.

  3. mheltone
    Member
    Posted 1 year ago #

    <?php query_posts('category_name=k9forsale&post_per_page=30'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    // contents here
    
    <?php endwhile; ?>
    <?php endif; ?>
    <?php wp_reset_query(); ?>

    Try this codes.

  4. AardvarkGirl
    Member
    Posted 1 year ago #

    If you guys have a better path then the one I am going down, by all means share... :) I really have no idea and headed into this blindly :)

    All I know is, I have a menu item (in the main menu system) that I need to go to a 'page' (or a list of posts, or however you want to word it) and show all the posts from just one category.

    I figured there was more than one road to China... I just picked one and started going. ;-)

    I'll give the code above a try (really, I am a total newbie to this, I need to take some tutorials on PHP and databases).

    ++++ Came back to say, I used the code above and got nothing, so I probably did something silly. ;-)

    Here is the URL:

    http://www.rastaging7.com/index.php/police-k9-training/k9forsale/

    So what other way would there be to accomplish what I want - keeping in mind I'll be handing this over to the site's owner (who is not going to be ultra savy, I want to keep things as simple for them as possible as far as keeping the ability for them to move pages around with in the menu, delete pages, add pages etc).

    Thanks folks so much! :)

  5. AardvarkGirl
    Member
    Posted 1 year ago #

    Or... I know in the side bar widgets you can view 'categories' - how would I get 'that' up into the main menu (ie with out an actual 'page') - would you use a custom menu?

    A little learning is a dangerous thing. ;-)

  6. mheltone
    Member
    Posted 1 year ago #

    That's weird that code usually works on me.
    Can you post your custom page here, So we can take a look.

  7. AardvarkGirl
    Member
    Posted 1 year ago #

    mheltone-

    right now it is the (twenty ten theme's) category.php, just renamed to 'category-k9forsale.php' (see code below, thats everything between the 'content' divs)... because as I admit, I'm green as grass. :)

    Again, if I am going about this the wrong way just say so. ;-)

    <h1 class="page-title"><?php printf( __( 'Category Archives: %s', 'twentyten' ), '<span>' . single_cat_title( '', false ) . '</span>' );?></h1>
    
    <?php $category_description = category_description();
    if ( ! empty( $category_description ) )
    echo '<div class="archive-meta">' . $category_description . '</div>';
    
    get_template_part( 'loop', 'category' );
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic