ThemeShaper Forums » Thematic

[closed]

change the style of index loop after a certain number of posts

(3 posts)
  • Started 12 years ago by awelch
  • Latest reply from awelch
  • This topic is not resolved

Tags:

  1. awelch
    Member

    Hi, I want to display the first 10 posts with a certain layout (e.g. full width) and then after than display the next 8 as excerpts, half-width floated boxes. what is the best way to do this?

    is it a case of changing the index loop as below?
    thanks in advance, andy

    function remove_index_loop() {
    remove_action('thematic_indexloop', 'thematic_index_loop');
    }
    add_action('init', 'remove_index_loop');

    function my_index_loop() {

    global $options, $blog_id;
    foreach ($options as $value) {
    if (get_option( $value['id'] ) === FALSE) {
    $$value['id'] = $value['std'];
    } else {
    if (THEMATIC_MB)
    {
    $$value['id'] = get_option($blog_id, $value['id'] );
    }
    else
    {
    $$value['id'] = get_option( $value['id'] );
    }
    }
    }
    /* Count the number of posts so we can insert a widgetized area */ $count = 1;
    while ( have_posts() ) : the_post();
    thematic_abovepost(); ?>

    <div id="post-<?php the_ID();
    echo '" ';
    if (!(THEMATIC_COMPATIBLE_POST_CLASS)) {
    post_class();
    echo '>';
    } else {
    echo 'class="';
    thematic_post_class();
    echo '">';
    }
    thematic_postheader(); ?>
    <div class="entry-content">
    <?php thematic_content(); ?>

    <?php wp_link_pages('before=<div class="page-link">' .__('Pages:', 'thematic') . '&after=</div>') ?>
    </div><!-- .entry-content -->
    <?php thematic_postfooter(); ?>
    </div><!-- #post -->

    <?php
    thematic_belowpost();
    comments_template();

    if ($count==$thm_insert_position) {
    get_sidebar('index-insert');
    }
    $count = $count + 1;
    endwhile;

    }
    add_action('thematic_indexloop', 'my_index_loop');

    Posted 12 years ago #
  2. you don't need to add and remove the action anymore. you can just use the built-in override functions

    function childtheme_override_index_loop() {
    
    global $options, $blog_id;
    foreach ($options as $value) {
    if (get_option( $value['id'] ) === FALSE) {
    $$value['id'] = $value['std'];
    } else {
    if (THEMATIC_MB)
    {
    $$value['id'] = get_option($blog_id, $value['id'] );
    }
    else
    {
    $$value['id'] = get_option( $value['id'] );
    }
    }
    }
    /* Count the number of posts so we can insert a widgetized area */ $count = 1;
    while ( have_posts() ) : the_post();
    
    if ($counter < 10 ) { 
    
    thematic_abovepost(); ?>
    
    <div id="post-<?php the_ID();
    echo '" ';
    if (!(THEMATIC_COMPATIBLE_POST_CLASS)) {
    post_class();
    echo '>';
    } else {
    echo 'class="';
    thematic_post_class();
    echo '">';
    }
    thematic_postheader(); ?>
    <div class="entry-content">
    <?php thematic_content(); ?>
    
    <?php wp_link_pages('before=<div class="page-link">' .__('Pages:', 'thematic') . '&after=</div>') ?>
    </div><!-- .entry-content -->
    <?php thematic_postfooter(); ?>
    </div><!-- #post -->
    
    <?php
    thematic_belowpost();
    comments_template();
    
    if ($count==$thm_insert_position) {
    get_sidebar('index-insert');
    }
    } else {
    
    //style your posts some other way after 10 posts
    
    }
    $count = $count + 1;
    endwhile;
    
    }

    i think i got the parens in the right place, but the general gist is to use the counter and use and if/else conditional

    Posted 12 years ago #
  3. awelch
    Member

    thanks!

    Posted 12 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.