ThemeShaper Forums » Thematic

Category posts to a page -

(4 posts)
  • Started 11 years ago by redhatgal
  • Latest reply from redhatgal
  • This topic is resolved

Tags:

  1. redhatgal
    Member

    Hi - I am working on adding posts from a category archive to a page template so that the visitor can select the category from the navigation menu. To do this I am using instructions from http://codex.wordpress.org/Pages#A_Page_of_Posts. I copied the code into a custom page template. It works except it lists all posts in all categories. I am unsure how to limit the posts to those in a certain category? I believe the PHP where I define which category is in this code that appears at the top. What do I modify so that posts only in a certain category appears on this page? Any other advice will be appreciated. I'm using Thematic version .9. - Amy

    <?php
    if (is_page('21') ) {
    $cat = array(12);
    } elseif ( is_page('16') ) {
    $cat = array(32);
    } elseif ( is_page('28') ) {
    $cat = array(17);
    } else {
    $cat = '';
    }

    Posted 11 years ago #
  2. redhatgal
    Member

    Hi again,

    I am trying out another approach - inserting some of the code from catalog.php in a custom page template, "page_events.php."

    For instance, I have an Events page which has a tab in the top navigation menu. This page is using the "page_events.php" template. On this page I want to display posts that are in the Events category. The category ID is 6.

    In the page_events.php I put between <div id="content"> </div><!-- #content --> the following code below from category.php. Needless to say this didn't quite work. I got the following error: Warning: preg_split() expects parameter 2 to be string, object given in /wp/wp-includes/formatting.php. I do not know what this means and how to fix it or is there another way to do this? -Amy


    <h1 class="page-title"><?php _e('Category Archives:', 'Events') ?> <span><?php echo single_cat_title(); ?></span></h1>
    <div class="archive-meta"><?php if ( !(''== category_description()) ) : echo apply_filters('archive_meta', category_description()); endif; ?></div>

    <div id="nav-above" class="navigation">
    <?php if(function_exists('wp_pagenavi')) { ?>
    <?php wp_pagenavi(); ?>
    <?php } else { ?>
    <div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">«</span> Older posts', 'thematic')) ?></div>
    <div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">»</span>', 'thematic')) ?></div>
    <?php } ?>
    </div>

    <?php while (have_posts()) : the_post(); ?>

    <div id="post-<?php the_ID(); ?>" class="<?php thematic_post_class(); ?>">
    <?php thematic_postheader(); ?>
    <div class="entry-content">
    <?php the_excerpt(''.__('Read More <span class="meta-nav">»</span>', 'thematic').'') ?>

    </div>
    <?php thematic_postfooter(); ?>
    </div><!-- .post -->

    <?php endwhile; ?>

    <div id="nav-below" class="navigation">
    <?php if(function_exists('wp_pagenavi')) { ?>
    <?php wp_pagenavi(); ?>
    <?php } else { ?>
    <div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">«</span> Older posts', 'thematic')) ?></div>
    <div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">»</span>', 'thematic')) ?></div>
    <?php } ?>
    </div>

    Posted 11 years ago #
  3. Hi,

    take a look here: Navigation - Adding Items

    Cheers,

    Chris

    Posted 11 years ago #
  4. redhatgal
    Member

    Hi Chris, I'm sorry I didn't see this earlier. Thanks for the information! I added it and it works great.

    Posted 11 years ago #

RSS feed for this topic

Reply

You must log in to post.