ThemeShaper Forums » Thematic

[closed]

using template-page-blog.php to show specific categories

(12 posts)
  • Started 3 years ago by chips
  • Latest reply from pnett
  • This topic is not resolved
  1. Hi,

    First off, thanks for the new release.

    I am trying to limit the posts displayed using template-page-blog.php to just one category, but I am struggling.

    I have tried adding a category to the query like this -

    <?php
    $wp_query = new WP_Query();
    $wp_query->query( array( 'category=21, posts_per_page' => get_option( 'posts_per_page' ), 'paged' => $paged ) );
    $more = 0;
    ?>

    But it seems to be the wrong way to go about it.

    Posted 3 years ago #
  2. it is the right way to do it, but 'category' is not a recognized parameter

    http://codex.wordpress.org/Function_Reference/query_posts

    try cat=21

    Posted 3 years ago #
  3. Thanks Helga, I already tried that aswell but unfortunately neither seems to work. Is this something I am doing wrong or a limitation of wordpress/thematic?

    Posted 3 years ago #
  4. tried

    category_name=blah
    Posted 3 years ago #
  5. Thanks Jonny, yeah I tried that too with no success.

    Posted 3 years ago #
  6. @chips
    i tried the following and it works

    <?php
    			$wp_query = new WP_Query();
    			$wp_query->query( array(
                            'category_name' => 'category-21',
                            'posts_per_page' => get_option( 'posts_per_page' ),
                            'paged' => $paged ) );
    			$more = 0;
    			?>
    Posted 3 years ago #
  7. maybe i shouldn't have called the category i tested 'category 21', may confuse matters.

    so bsically,
    add

    'category_name' => 'mycategoryname',
    Posted 3 years ago #
  8. Hi Jonny,

    Thanks again for your help. It worked perfectly, although I used instead;

    'cat' => '21'

    Great!
    Thanks ;o)

    Posted 3 years ago #
  9. sweet. 21 is the magic number

    Posted 3 years ago #
  10. I have also had ago at doing this but I am only getting the first 4 or 5 lines of the post showing up on my single category page. The first few lines are followed by [...] which would be ok ish if it were clickable to the single page version. On my main news page that shows all the categories except this one (cat 5) I see the whole post. Any ideas why?

    Posted 3 years ago #
  11. citizenplane
    Member

    Hi all,

    @jonny this works for me:

    $wp_query = new WP_Query();
    $wp_query->query( array(
    'category_name' => 'category-21',
    'posts_per_page' => get_option( 'posts_per_page' ),
    'paged' => $paged ) );
    $more = 0;

    But for some reason the page shows only the latest post in that category.
    Am I missing some parameter that limits the displayed results?

    Thanks again

    Posted 2 years ago #
  12. pnett
    Member

    Hi. Similar issues on my site as well. Only I can get it to work, but.. my sidebar disappears!

    I added this code to functions.php so that I can display the full post:

    function childtheme_content($content) {
    if (is_category('blog')) {
    $content= 'full';
    }
    return $content;
    }
    add_filter('thematic_content', 'childtheme_content');

    In my template-page-blog.php I made this adjustment:

    <?php
    $wp_query = new WP_Query();
    $wp_query->query( array( 'posts_per_page' => get_option( 'posts_per_page' ), 'paged' => $paged, 'category_name' => 'blog' ) );
    $more = 0;
    ?>

    Now, it works, I get my full post from the 'blog' category, but, my the sidebar stops showing up. Any ideas?

    Here is a link:

    http://www.kabntr.org/blog/

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.