WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Use page as category? (6 posts)

  1. Ignacio
    Member
    Posted 5 years ago #

    I´m sorry if this has been already asked, but i couldn´t find it anywhere.

    What i need is to add the code on a page to display as a category.
    This is so i can have the pages and categories in only one menu.

    i.e.: i go to the page "about us" and it shows (as if it was redirecting) the category 1, that includes all posts on who we are...

    can it be done?
    thanks in advance!

  2. Eric Amundson
    Volunteer Moderator
    Posted 5 years ago #

    You can do this using several different methods.

    One would be to really just have a custom category page that pulls only posts from a single category.

    Another would be to have a page with a custom loop that only does the above.

    You may want to read some of the docs like:
    http://codex.wordpress.org/Templates_Hierarchy
    http://codex.wordpress.org/Templates_Hierarchy#Category_page
    http://codex.wordpress.org/Category_Templates
    http://codex.wordpress.org/The_Loop

  3. Ignacio
    Member
    Posted 5 years ago #

    One would be to really just have a custom category page that pulls only posts from a single category.

    that´s exactly it!
    but even though i read the articles you sent me (i really did), i couldn´t figure out how to do that. i know it should be really easy, but the loop examples don´t show how to limit it to a category, but how to exclude one...

    any further info will be really appreciated! :)

  4. Eric Amundson
    Volunteer Moderator
    Posted 5 years ago #

    Look on the Category_Templates page under "What categories do you show to the visitors? " - I think that'll get you what you need.

  5. Ignacio
    Member
    Posted 5 years ago #

    thanks a lot for your help!
    i finally solved it.

    if someone needs to do this, here´s the solution.
    i was using k2 as theme, so i made a new template file like this:

    <?php /*
    	Template Name: Category id 5
    */ ?>
    
    <?php get_header(); ?>
    
    <div class="content">
    	<div id="primary">
    		<div id="current-content" class="hfeed">
    
    		<?php query_posts('cat=5&showposts='.get_option('posts_per_page')); ?>
    
    		<?php include('theloop.php'); ?>
    
    		</div> <!-- #current-content -->
    
    		<div id="dynamic-content"></div>
    	</div> <!-- #primary -->
    
    	<?php get_sidebar(); ?>
    
    </div> <!-- .content -->
    
    <?php get_footer(); ?>

    as you can see, i used the query_posts to limit it to category 5. then, i created a new page in wordpress that is almost empty, but on the bottom i selected this template file.

    as easy as that!

  6. terrybolas
    Member
    Posted 5 years ago #

    Still don't get it

    Is there any better tutorial for this?

Topic Closed

This topic has been closed to new replies.

About this Topic