ThemeShaper Forums » Thematic

[closed]

location of "indexloop"

(8 posts)
  • Started 4 years ago by xxxevilgrinxxx
  • Latest reply from helgatheviking
  • This topic is resolved
  1. I've been peeking through all of the Thematic files, trying to get a real feel for it before I start to tinker and one of the first things I tend to look for is the loop. I feel like a bit of a bonehead here because it should just leap out at me, but I can't easily locate it. Is it the blurb in 'archives.php'?
    thanks in advance :)

    Posted 4 years ago #
  2. Hi,

    thematic_indexloop() is only an action hook. The index loop itself is defined with thematic_index_loop(). You can find it in thematic/library/extensions/content-extensions.php (line 256 - 279).

    Chris

    Posted 4 years ago #
  3. thank you very much, Chris.

    The action hooks are all a little new to me (I'm guessing they won't be by the time I'm done playing with Thematic *chuckles* )

    off to play...

    Posted 4 years ago #
  4. adding on here, as I tinker some more...

    Now that I know where the loop is [:D] I'd like to monkey around with it. What I'd like to do is change the loop in my child theme only so that it won't be touched when Thematic gets upgraded.

    Can I move the loop to my functions.php file and tinker with it there? Should I? Will it blow up?
    If anyone has suggestions, I'd love to hear from you :)

    Posted 4 years ago #
  5. amygail
    Member

    here's a series of posts that should keep help you (not) blow things up

    http://themeshaper.com/modify-wordpress-themes/

    Specially, read the post about action hooks

    Posted 4 years ago #
  6. wonderful!
    off I go again to see what mischief I can get up to with my test blog :D

    *wow, I'll never think of "bacon" the same way again! What a fantastic example, and exactly what I needed to get over my fear...and make me a little hungry at the same time = WIN! *

    Posted 4 years ago #
  7. I know this is an ancient post so forgive me:

    The function for the index loop is:

    function thematic_indexloop() {
    do_action('thematic_indexloop');
    } // end thematic_indexloop

    To me, this looks like a dead end. How can I alter the behavior in my own child theme?

    Posted 2 years ago #
  8. that isn't a dead end. that is just the beginning.. actually it is the definition of an action HOOK. look into the library/extensions folder to see how deep the rabbit hole goes.

    oh hai there.... you'll find :

    // The Index Loop
    if (function_exists('childtheme_override_index_loop'))  {
    	function thematic_index_loop() {
    		childtheme_override_index_loop();
    	}
    } else {
    	function thematic_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;
    	}
    } // end index_loop
    
    add_action('thematic_indexloop', 'thematic_index_loop');

    very last line says that the function thematic_index_loop() has been added to that hook you found, thematic_indexloop() yes there IS a one HYPHEN difference between the hook and the function that gets added to it.

    edited to add: don't go changing stuff in the extensions folder. copy the whole thematic_index_loop() function into your child's functions.php, rename the function to childtheme_override_index() and then hack away. if you look at the above function, you'll not that thematic checks for the presence of that function and will preferentially use your function before falling back on its own loop function.

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.