Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #12191

    I want the pages to display similar to the home page. I’ve created templates for the pages “Relationship,Teens,Etc” and need to know how to only display 1 category in the code.

    Here is the code I’ve grabbed from the home page. It works great as it inserts ALL blog posts. I just want ONE category though.

    // ############################# FULL SIZED POSTS #############################

    if ($fullsized > 0) :

    $preview_image = kriesi_post_thumb($post->ID, array(‘size’=> array(‘M’),

    ‘display_link’ => ‘_prev_image_link’,

    ‘linkurl’ => array (‘L’,'_preview_big’),

    ‘wh’ => $k_option

    ));

    ?>

    <div class=”entry <?php if(!$preview_image) echo ‘entry-no-pic’;?>”>

    <?php

    if($preview_image)

    {

    echo ‘<div class=”entry-previewimage rounded preloading_background”>’;

    echo $preview_image;

    echo ‘</div>’;

    }

    ?>

    <div class=”entry-content”>

    <h1 class=”entry-heading”>

    ” rel=”bookmark” title=”<?php _e(‘Permanent Link:’,'newscast’)?> <?php the_title(); ?>”>

    <?php the_title(); ?>

    </h1>

    <div class=”entry-head”>

    <span class=”date ie6fix”><?php the_time(‘M d, Y’) ?></span>

    <span class=”comments ie6fix”><?php comments_popup_link(__(‘No Comments’,'newscast’), __(’1 Comment’,'newscast’), __(‘% Comments’,'newscast’)); ?></span>

    <span class=”author ie6fix”><?php _e(‘by’,'newscast’);?> <?php the_author_posts_link(); ?></span>

    </div>

    <div class=”entry-text”>

    <?php the_excerpt() ?>

    </div>

    <div class=”entry-bottom”>

    <span class=”categories”><?php the_category(‘, ‘); ?></span>

    ” class=”more-link”><?php _e(‘Read more’,'newscast’); ?>

    </div>

    </div><!–end entry_content–>

    </div><!–end entry –>

    <?php

    $fullsized–;

    else:

    // ############################# SMALL SIZED POSTS #############################

    if($smallsized == 1): echo ‘<div class=”doubleentry”>’; endif;

    $smallsized ++;

    $small_prev = kriesi_post_thumb($post->ID, array(‘size’=> array(‘S’),

    ‘display_link’ => ‘_prev_image_link’,

    ‘linkurl’ => array (‘L’,'_preview_big’),

    ‘wh’ => $k_option,

    ‘img_attr’ => array(‘class’=>’rounded alignleft’),

    ‘link_attr’ => array(‘class’=>’alignleft preloading_background’)

    ));

    ?>

    <div class=”entry”>

    <div class=”entry-content”>

    <h1 class=”entry-heading”>

    ” rel=”bookmark” title=”<?php _e(‘Permanent Link:’,'newscast’)?> <?php the_title(); ?>”>

    <?php the_title(); ?>

    </h1> <div class=”entry-head”>

    <span class=”date ie6fix”><?php the_time(‘M d, Y’) ?></span>

    <span class=”comments ie6fix”><?php comments_popup_link(__(‘No Comments’,'newscast’), __(’1 Comment’,'newscast’), __(‘% Comments’,'newscast’)); ?></span>

    </div>

    <div class=”entry-text”>

    <?php

    if($small_prev) echo $small_prev;

    the_excerpt();

    ?>

    </div>

    <div class=”entry-bottom”>

    ” class=”more-link”><?php _e(‘Read more’,'newscast’); ?>

    </div>

    </div>

    </div>

    <?php

    if($smallsized > 2): echo ‘</div>’; $smallsized = 1; endif;

    endif; endwhile;

    if($smallsized == 2):echo ‘</div>’; endif;

    kriesi_pagination($additional_loop->max_num_pages);

    else:

    echo’<div class=”entry”>’;

    echo’<h2>’.__(‘Nothing Found’,'newscast’).’</h2>’;

    echo’<p>’.__(‘Sorry, no posts matched your criteria’,'newscast’).’</p>’;

    echo’</div>’;

    endif;

    // end content: ?>

    <?php

    endwhile;

    else:

    echo’<div class=”entry”>’;

    echo’<h2>’.__(‘Nothing Found’,'newscast’).’</h2>’;

    echo’<p>’.__(‘Sorry, no posts matched your criteria’,'newscast’).’</p>’;

    echo’</div>’;

    endif;

    // end content: ?></div>

    #74633

    Basically you just need to duplicate index.php and rename the copy archive.php. Then replace

    $additional_loop = new WP_Query("cat=".$negative_cats."&paged=$paged");

    if ($additional_loop->have_posts()) :
    while ($additional_loop->have_posts()) : $additional_loop->the_post();

    with:

    if (have_posts()) :
    while (have_posts()) : the_post();

    Some other adjustments are required – eg you can remove the slider, etc.

    #74634

    how do I select what category I want to display?

    #74635

    WP uses the standard query if you don’t add aditional parameters. It will use the category which is requested by the user. It doesn’t make much sense to add custom categories the archive template (eg by “hardcoding” the categories).

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Want To Create Template – Display Posts like homepage but from Category’ is closed to new replies.