Support » Fixing WordPress » Showing specific category in template

  • Hello… I am trying to create a newsletter using a theme and I am able to display the content of my homepage without problems… but my issue is that I want to display ONLY those items that I choose by posting them under the “Newsletter” category but excluding them from the homepage… can that be done?

    i have tried using the category exclusion plugin but it also affects my themes… so I need to have a code that can let me do this w/o having to use the cat exclude plug in… is there a fix for that?

    I also want to be able to control the number of posts that should show in that theme (template) without having to use the WP settings…

Viewing 6 replies - 1 through 6 (of 6 total)
  • I also need this.. Anyone?

    Brilliant! Thanks.

    That has solved 1 of 2 problems

    The index page now show posts from my ‘news’ catorgory thanks to your post. Now how can I show other posts from other catogories on seperate pages?

    For example – I have a main news page (index.php which now works) and a blog page where my contributers will add book reviews. How do I go about setting up the blog page so that it just shows entries from my blog catogory?

    Thread Starter mrosarionyc

    (@mrosarionyc)

    thanks!!!

    Does this help at all…

    Add a new page called ‘blog’. Then create a template called ‘blog’. To create a template called blog make a copy of your ‘page.php’ file from your current theme and rename it to blog.php. Then give it 777 rights via ftp so you can modify it in wordpress.

    Locate the page you have just called blog.php in Appearance/Editor and add this to the top of the page:

    <?php
    /*
    Template Name: Blog
    */
    ?>

    Save it.

    Then go to Pages/Edit and open your page claled ‘Blog’. Under the Attributes section there is a template dropdown option where you can now select your template page that you just created called ‘Blog’. Select it and save.

    Go back to your template blog.php and you can then start to make this page how you want it to look. where you wnt your blog to appear add in this: (tweak the css to your own css and edit in or out the bits that you need or don’t need. So take out the <– bits if you want to see what is displayed)

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <h2><?php the_title(); ?></h2>
    <!--<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>-->
    <!--<h2>
     <?php
     // this is where the category title gets printed
     wp_list_categories('include=3&title_li=&style=none'); ?></h2>-->
    <div class="post">
    <?php $recent = new WP_Query("category_name=blog&showposts=50"); while($recent->have_posts()) : $recent->the_post();?>
    <h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    <p><?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?> | <?php the_category(', ') ?> | <?php the_author('nickname'); ?> | <?php comments_popup_link('Comment', '1 Comment', '% Comments'); ?></p>
    <p><?php the_content(__(''));?></p>
    <?php endwhile; ?>
    <p><span class="small">More <?php wp_list_categories('include=&title_li=&style=none'); ?></span></p>
    </div>

    You will need to change the option where it says include=3 to be the number ID of your blog category.

    You can also change the number of posts that it displayes…showposts=50 change that number.

    Set category_name=blog

    This may not be ideal but its one way.

    That is a brilliant post. Many thanks for your time.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Showing specific category in template’ is closed to new replies.