ThemeShaper Forums » Thematic

[closed]

Changing where post-thumbnail / featured image appears in the post

(3 posts)
  • Started 8 years ago by krackpot
  • Latest reply from krackpot
  • This topic is not resolved
  1. krackpot
    Member

    I'm trying to change where the post thumbnail shows up in the post. Instead of having it in the content, I want it in a separate div inside the div with the ID.

    What I have so far in my functions.php file:

    // Creates the post content
    function childtheme_override_content() {
    	global $thematic_content_length;
    
    	if ( strtolower($thematic_content_length) == 'full' ) {
    		$post = get_the_content(more_text());
    		$post = apply_filters('the_content', $post);
    		$post = str_replace(']]>', ']]>', $post);
    	} elseif ( strtolower($thematic_content_length) == 'excerpt') {
    		$post = '';
    		$post .= get_the_excerpt();
    		$post = apply_filters('the_excerpt',$post);
    	} elseif ( strtolower($thematic_content_length) == 'none') {
    	} else {
    		$post = get_the_content(more_text());
    		$post = apply_filters('the_content', $post);
    		$post = str_replace(']]>', ']]>', $post);
    	}
    	echo apply_filters('thematic_post', $post);
    }
    // end content
    
    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();
    
    				thematic_abovepost(); ?>
    
    				<div id="post-<?php the_ID();
    					echo '" ';
    					if (!(THEMATIC_COMPATIBLE_POST_CLASS)) {
    						post_class();
    						echo '>';
    					} else {
    						echo 'class="';
    						thematic_post_class();
    						echo '">';
    					}
    					?>
    					<div class="entry-postthumb">
    					<?php
    					if ( apply_filters( 'thematic_post_thumbs', TRUE) ) {
    						$post_title = get_the_title();
    						$size = apply_filters( 'thematic_post_thumb_size' , array(100,100) );
    						$attr = apply_filters( 'thematic_post_thumb_attr', array('title'	=> 'Permalink to ' . $post_title) );
    						if ( has_post_thumbnail() ) {
    							$post = '<a href="' . get_permalink() . '" title="Permalink to ' . get_the_title() . '">' . get_the_post_thumbnail(get_the_ID(), $size, $attr) . '</a>' . $post;
    							}
    					}
    					?>
    					</div>
    					<div class="entry-entry">
    					<?php
         				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>
    				</div><!-- #post -->
    
    			<?php 
    
    				thematic_belowpost();
    				comments_template();
    				if ($count==$thm_insert_position) {
    						get_sidebar('index-insert');
    				}
    				$count = $count + 1;
    		endwhile;
    
    } // end index_loop

    I basically just cut and paste the chunk of code relating to the post thumbnail in the original thematic_content() function and put it into the thematic_index_loop() function.

    The error I get is:
    "Notice: Undefined variable: post in functions.php on line 356"

    which is this line:

    $post = '<a href="' . get_permalink() . '" title="Permalink to ' . get_the_title() . '">' . get_the_post_thumbnail(get_the_ID(), $size, $attr) . '</a>' . $post;

    Somehow when it runs my child theme, the variable is being called before it has a chance to be declared? (my functions.php file first, then the thematic functions.php is loaded?)

    What am I missing? (I'm a newbie to php etc)

    Posted 8 years ago #
  2. Hi,

    Try replacing:

    <?php
     if ( apply_filters( 'thematic_post_thumbs', TRUE) ) {
      $post_title = get_the_title();
      $size = apply_filters( 'thematic_post_thumb_size' , array(100,100) );
      $attr = apply_filters( 'thematic_post_thumb_attr', array('title'	=> 'Permalink to ' . $post_title) );
      if ( has_post_thumbnail() ) {
        $post = '<a href="' . get_permalink() . '" title="Permalink to ' . get_the_title() . '">' . get_the_post_thumbnail(get_the_ID(), $size, $attr) . '</a>' . $post;
      }
    }
    ?>

    with:

    the_post_thumbnail();

    -Gene

    Posted 8 years ago #
  3. krackpot
    Member

    Thanks again em hr! I don't know why I made it so complicated :)

    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.