SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: I need help on this wordpress category template

Hybrid View

  1. #1
    SitePoint Enthusiast TopherX's Avatar
    Join Date
    Sep 2008
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I need help on this wordpress category template

    I want to make a category template for this new site:

    http://www.archos-video.com

    I want the template to first call a page with the same name as the category, then rewind and call the posts in that category. That way each category will have a unique introduction paragraph controlled by a page in the WP admin.

    Here's what I have so far:

    PHP Code:
    <?php get_header(); ?>
    <div id="contentwrap">
    <?php include(TEMPLATEPATH."/featured.php");?>
        <div id="content" class="narrowcolumn">
                  <div class="navigation_small">
                  
                <div class="alignleft"><?php next_posts_link('&laquo; Older Entries'?></div>
                <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;'?></div>
                  
                   </div>
            <?php if (have_posts()) : ?>

          
            <h2 class="pagetitle">Category: <?php single_cat_title(); ?></h2>
         

    <?php $category get_the_category();?> 
    <?php query_posts('pagename=$category->category_nicename'); ?>

        <?php while (have_posts()) : the_post(); ?>
            <div class="post">
                    <h3 id="post-<?php the_ID(); ?>"><a href="<?php bloginfo('url'); ?>/<?php echo($post->post_name?> " rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
                    <small><?php the_time('l, F jS, Y'?></small>

                    <div class="entry">
                        <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
                    </div>

                    <h6 class="postmetadata"><?php the_tags('Tags: '', ''<br />'); ?> Posted in <?php the_category(', '?> | <?php edit_post_link('Edit'''' | '); ?>  <?php comments_popup_link('No Comments »''1 Comment »''% Comments »'); ?></h6>

                </div>

            <?php endwhile; ?>

        <?php endif; ?>


    <?php rewind_posts(); ?>

    <?php query_posts('category_name='.$category); ?>
            
    <?php if (have_posts()) : ?>
            <?php while (have_posts()) : the_post(); ?>
            <div class="post">
                    <h3 id="post-<?php the_ID(); ?>"><a href="<?php bloginfo('url'); ?>/<?php echo($post->post_name?> " rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
                    <small><?php the_time('l, F jS, Y'?></small>

    <a href="<?php bloginfo('url'); ?>/<?php echo($post->post_name?>" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('playbutton<?php echo($post->post_name?>','','<?php bloginfo('stylesheet_directory'); ?>/images/playbutton_flip.png',1)"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/playbutton.png" name="playbutton<?php echo($post->post_name?>" width="150" height="150" border="0" id="playbutton" style="float:right;padding-left:10px;" /></a>

                    <div class="entry">
                        <?php the_excerpt(); ?>
                    </div>

                    <h6 class="postmetadata"><?php the_tags('Tags: '', ''<br />'); ?> Posted in <?php the_category(', '?> | <?php edit_post_link('Edit'''' | '); ?>  <?php comments_popup_link('No Comments »''1 Comment »''% Comments »'); ?></h6>

                </div>

            <?php endwhile; ?>

            <div class="navigation_small">
                <div class="alignleft"><?php next_posts_link('&laquo; Older Entries'?></div>
                <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;'?></div>
            </div>

        <?php endif; ?>

        </div>

    <?php get_sidebar(); ?>
    </div>
    <?php get_footer(); ?>

    Basically I'm getting nothing right now...lol

    http://www.archos-video.com/category/captain-euchre/


    Now I know my php skills suck so I'm hoping one of you will have the answer for this.

    First I I'm pretty sure I have a problem in the query of the page:

    PHP Code:
    <?php $category get_the_category();?> 

    <?php query_posts('pagename=$category->category_nicename'); ?>
    Second I think I'm messing up the query for the category

    PHP Code:
    <?php rewind_posts(); ?>

    <?php query_posts('category_name='.$category); ?>
            
    <?php if (have_posts()) : ?>
            <?php while (have_posts()) : the_post(); ?>
    I'm really just shooting blanks at this point so any idea will be welcome.

  2. #2
    SitePoint Enthusiast TopherX's Avatar
    Join Date
    Sep 2008
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I figured it out...

    you have to concatenate the query first.

    PHP Code:
    <?php
    $category 
    get_the_category();
    $catslugger$category[0]->category_nicename;
    $query'pagename=' $catslugger;
    query_posts($query);
    ?>
    and

    PHP Code:
    <?php
    $query
    'category_name=' $catslugger;
    query_posts($query);
    ?>

    I'm starting to get the hang of this.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •