Forums

Category 'posts' on a page - finding info that isn't 2 years old (3 posts)

  1. AardvarkGirl
    Member
    Posted 1 year ago #

    I'm digging around and am finding a mis-mash of info about this, but a lot of it is dated from 2 years ago and I'm not sure how valid it is.

    What I am trying to accomplish, in laymens terms, is to have a PAGE (that shows up in the menu system, and a page where possibly the site owner can have a paragraph of general info but then...) where the posts of a particular category are showing up.

    I feel like I'm warm... but maybe going down the wrong path (I created the 'page' an then am using a template called category-k9s.php) uh... but I'm not sure if I'm heading towards the right direction here.

    :)

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    http://codex.wordpress.org/Pages#A_Page_of_Posts is one option. Creating a category-specific template file is another. Both of these options are still valid.

  3. AardvarkGirl
    Member
    Posted 1 year ago #

    Thanks ESMI. I was reading that article as I created this thread.

    I've only been using WordPress as a CMS for a few months now as a 'developer' (using it to build sites for others), and have just recently started using WordPress as an actual site owner (ie acutally USING WP not just building with it) - so a lot of this I'm just discovering.

    So I've got the code from the article above -

    <?php
    if (is_page() ) {
    $category = get_post_meta($posts[0]->ID, 'category', true);
    }
    if ($category) {
      $cat = get_cat_ID($category);
      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
      $post_per_page = 4; // -1 shows all posts
      $do_not_show_stickies = 1; // 0 to show stickies
      $args=array(
        'category__in' => array($cat),
        'orderby' => 'date',
        'order' => 'DESC',
        'paged' => $paged,
        'posts_per_page' => $post_per_page,
        'caller_get_posts' => $do_not_show_stickies
      );
      $temp = $wp_query;  // assign orginal query to temp variable for later use
      $wp_query = null;
      $wp_query = new WP_Query($args);
      if( have_posts() ) :
    		while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    	    <div <?php post_class() ?> id="post-<?php the_ID(); ?>">

    (truncated)

    ...in my custom page template (category-k9forsale.php) and I've got the page in question (http://www.rastaging7.com/index.php/police-k9-training/k9-for-sale-blog-style/) using this template.

    I've created a category for these posts (the slug is' k9forsale').

    In the php for the page template am I using the category slug name... (getting dazed and confused)...

    <?php
    if (is_page() ) {
    $category = get_post_meta($posts[0]->ID, 'category', true);

    And thanks, I honestly have been trying to look this up but keep finding 'tutorials' from over a year+ ago.

    Oh wait... wait... does 'pulling in the specific category (posts)' have something to do with Custom Fields for that page... hmmm.

Topic Closed

This topic has been closed to new replies.

About this Topic