ThemeShaper Forums » Thematic

[closed]

Please help me with post thumbnail positioning and remove content text

(19 posts)
  • Started 8 years ago by mrmikeman
  • Latest reply from mrmikeman
  • This topic is resolved
  1. mrmikeman
    Member

    Hi, I have tried so hard to figure it out myself and by researching it, I just can't figure it out..

    on http://ocixx.com/shirleyhealth/

    I am trying to do a couple things, that I have tried to do now for the past several weeks.

    One: position medium post thumbs/feature images, in rows of 3.
    Two: remove the textual content from the post, from the home page.
    Three: remove post thumbnail/feature image from single post pages.

    Im trying to accomplish this with a child theme that I have up.
    Thank you all for your time

    Posted 8 years ago #
  2. 1. http://forums.themeshaper.com/topic/show-blog-title-only-for-preview

    2. http://hardiannazief.com/12/create-custom-posts-layout-in-home-page-thematic-child-theme/

    3. the featured image is not auto-added to single posts, you must have inserted the image into the content for it to appear where it it. also you are still using full content on the home page as otherwise (w/o filtering the wp_trim_excerpt function) you wouldn't have pictures on the front page.

    Posted 8 years ago #
  3. mrmikeman
    Member

    all i have in my functions php is

    function add_post_thumb($title) {
    return get_the_post_thumbnail(NULL, 'medium') . $title;
    }
    add_filter('get_the_excerpt', 'add_post_thumb');
    add_filter('the_content', 'add_post_thumb');

    function childtheme_override_postheader_postmeta(){
    //the sound of one hand clapping
    }

    i removed each line one by one for the post thumbnail to try and get rid of the post thumbnail on the single post pages but it doesnt work,

    Posted 8 years ago #
  4. why do you have this?

    function add_post_thumb($title) {
    return get_the_post_thumbnail(NULL, 'medium') . $title;
    }
    add_filter('get_the_excerpt', 'add_post_thumb');
    add_filter('the_content', 'add_post_thumb');

    this is the reason that thumbs are appearing on the single post pages (you've added them to the_content) without any sort of conditional logic to say DON'T put them on single pages

    also you don't need to add it to excerpts as thumbs are already in thematic excerpts. you could just filter their size.

    Posted 8 years ago #
  5. mrmikeman
    Member

    i understand the tags i just dont understand how to place them.. i tried

    function add_post_thumb($title) {
    return get_the_post_thumbnail(NULL, 'medium') . $title;
    if (is_home()) {
    // Yes, we are .. now we switch off the sidebar
    return FALSE;
    } else {
    // we are not .. we leave the switch on
    return TRUE;
    }
    }
    add_filter('get_the_excerpt', 'add_post_thumb');
    add_filter('the_content', 'add_post_thumb');

    but it doesnt do anything

    Posted 8 years ago #
  6. mrmikeman
    Member

    forgive the comments in there i havnt removed them, i copied it from a help post you sent me to fir the sidebar :-D

    Posted 8 years ago #
  7. yeah that function works gangbusters if you are filter the thematic_sidebar which you aren't doing so you've got some frankenfunction and i'm not surprised it isn't doing anything.

    i will repeat #3 from above: the featured image is NOT auto-added to single posts. you have added it with this bit of code:

    add_filter('the_content', 'add_post_thumb');

    how about you try the following instead:

    function childtheme_content($content){
       if(is_home()){
          $content = 'image';
       }
      return $content;
    }
    add_filter('thematic_content','childtheme_content');
    
    function childtheme_image_post($post){
      global $thematic_content_length;
      if ( strtolower($thematic_content_length) == 'image' ) {
         $post = '';
         if ( has_post_thumbnail() ) {
    	$post .= '<a class="entry-thumb" href="' . get_permalink() . '" title="Permalink to ' . get_the_title() . '" >' . get_the_post_thumbnail(get_the_ID(), 'medium') . '</a>';
    	}
      }
    return $post
    
    }
    add_filter('thematic_post','childtheme_image_post');

    untested, so there could be typos

    Posted 8 years ago #
  8. mrmikeman
    Member

    thank you helg, i replace
    function add_post_thumb($title) {
    return get_the_post_thumbnail(NULL, 'medium') . $title;
    }
    add_filter('get_the_excerpt', 'add_post_thumb');
    add_filter('the_content', 'add_post_thumb');

    with what you gave me, i looked at the code i dont notice any typos, but it just brakes the site.. :-/

    Posted 8 years ago #
  9. missing a ;

    function childtheme_contenta($content){
       if(is_home()){
          $content = 'image';
       }
      return $content;
    }
    add_filter('thematic_content','childtheme_contenta');
    
    function childtheme_image_post($post){
      global $thematic_content_length;
      if ( strtolower($thematic_content_length) == 'image' ) {
         $post = '';
         if ( has_post_thumbnail() ) {
    	$post .= '<a class="entry-thumb" href="' . get_permalink() . '" title="Permalink to ' . get_the_title() . '" >' . get_the_post_thumbnail(get_the_ID(), 'medium') . '</a>';
    	}
      }
    return $post;
    
    }
    add_filter('thematic_post','childtheme_image_post');

    additionally- i highly recommend throwing your site into debug mode when you are developing stuff. it tells you in 2 seconds what is breaking the site (in this case a missing semi-colon)

    http://www.wprecipes.com/how-to-easily-enabledisable-debug-mode-in-wordpress

    Posted 8 years ago #
  10. mrmikeman
    Member

    debugging mode? ill wasnt aware of that ill find it, i really appreciate your help helg, but it seems now that my post thumbnails are gone, both single, and my front page.

    Posted 8 years ago #
  11. yes debug mode tells you what is causing the white screen of death, so you can actually do something about it.

    i can confirm that the code i just posted will put thumbnails on the home page (assuming your home page is set to show the latest blog posts)

    also you said in your original post that you wanted to remove thumbnails from single posts. they aren't there by default. you added them for some reason.

    Posted 8 years ago #
  12. mrmikeman
    Member

    im working out of a child theme, the one that came with thematic, i copied code over when i was trying to get post thumbnails to show, so i dont know what it was calling them on the single page, i replaced what i said i replaced above, with the new code you gave me. this is my functions php file, i didnt change anything so i dont know how its not pulling the thumbs now on my front page

    <?php

    //
    // Custom Child Theme Functions
    //

    // I've included a "commented out" sample function below that'll add a home link to your menu
    // More ideas can be found on "A Guide To Customizing The Thematic Theme Framework"
    // http://themeshaper.com/thematic-for-wordpress/guide-customizing-thematic-theme-framework/

    // Adds a home link to your menu
    // http://codex.wordpress.org/Template_Tags/wp_page_menu
    //function childtheme_menu_args($args) {
    // $args = array(
    // 'show_home' => 'Home',
    // 'sort_column' => 'menu_order',
    // 'menu_class' => 'menu',
    // 'echo' => true
    // );
    // return $args;
    //}
    //add_filter('wp_page_menu_args','childtheme_menu_args');

    // Unleash the power of Thematic's dynamic classes
    //
    // define('THEMATIC_COMPATIBLE_BODY_CLASS', true);
    // define('THEMATIC_COMPATIBLE_POST_CLASS', true);

    // Unleash the power of Thematic's comment form
    //
    // define('THEMATIC_COMPATIBLE_COMMENT_FORM', true);

    // Unleash the power of Thematic's feed link functions
    //
    // define('THEMATIC_COMPATIBLE_FEEDLINKS', true);

    function childtheme_contenta($content){
    if(is_home()){
    $content = 'image';
    }
    return $content;
    }
    add_filter('thematic_content','childtheme_contenta');

    function childtheme_image_post($post){
    global $thematic_content_length;
    if ( strtolower($thematic_content_length) == 'image' ) {
    $post = '';
    if ( has_post_thumbnail() ) {
    $post .= '' . get_the_post_thumbnail(get_the_ID(), 'medium') . '';
    }
    }
    return $post;

    }
    add_filter('thematic_post','childtheme_image_post');
    function childtheme_override_postheader_postmeta(){

    //the sound of one hand clapping
    }

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

    function snippet_index_loop() {
    global $post;
    /* Count the number of posts so we can insert a widgetized area */ $count = 1;
    while ( have_posts() ) : the_post() ?>
    <?php $counter++; ?>
    <div class="column <?php if ($counter == 1) { echo 'one'; } else { echo 'two'; $counter = 0; } ?>">
    <div class="clear-fix">
    <div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
    <?php thematic_postheader(); ?>
    <div class="entry-content">
    <?php the_excerpt(); ?>
    <?php wp_link_pages('before=<div class="page-link">' .__('Pages:', 'thematic') . '&after=</div>') ?>
    </div>
    <?php thematic_postfooter(); ?>
    </div><!-- .post -->
    </div><!-- .clear-fix -->
    </div><!-- .column -->

    <?php comments_template();
    if ($count==$thm_insert_position) { get_sidebar('index-insert');}

    $count = $count + 1;
    endwhile;
    }
    add_action('thematic_indexloop', 'snippet_index_loop');

    // filter thematic_sidebar() .. no display for the page 'Forum', keep it for the rest
    function remove_sidebar() {
    // We test if we are on the page 'Forum'
    if (is_home()) {
    // Yes, we are .. now we switch off the sidebar
    return FALSE;
    } else {
    // we are not .. we leave the switch on
    return TRUE;
    }
    }
    // Connect the filter to thematic_sidebar()
    add_filter('thematic_sidebar', 'remove_sidebar');

    //different style sheet for the homepage
    // filter thematic_create_stylesheet to implement your own stylesheets
    function my_stylesheet($content) {
    // We test if we're on home or on your frontpage
    if (is_home() || is_front_page()) {
    // yes, we are .. now let's load the 3c-fixed layout
    $content = "\t";
    $content .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
    $content .= get_bloginfo('stylesheet_directory') . "/style-home.css";
    $content .= "\" />";
    $content .= "\n\n";
    } else {
    // we are not .. let's load the 2c-r-fixed layout
    $content = "\t";
    $content .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
    $content .= get_bloginfo('stylesheet_directory') . "/style.css";
    $content .= "\" />";
    $content .= "\n\n";
    }
    // $content will be handed back to thematic_create_stylesheet
    return $content;
    }
    // connect the filter to thematic_create_stylesheet
    add_filter ('thematic_create_stylesheet', 'my_stylesheet');
    //end different style sheet for the homepage

    ?>

    Posted 8 years ago #
  13. well the_excerpt() will always return the excerpt no matter what. i didn't know you had that in there, so of course, my code wasn't working.

    try this:

    function childtheme_content($content) {
    	if ( is_home () ) {
    		$content= 'image';
    	}
    	return $content;
    }
    add_filter('thematic_content', 'childtheme_content');
    
    function childtheme_image_post($post){
    global $thematic_content_length;
    
    	if ( strtolower($thematic_content_length) == 'image' ) {
    	$post = '';
    		if ( has_post_thumbnail() ) {
    		$post .= '' . get_the_post_thumbnail(get_the_ID(), 'medium') . '';
    		}
    	}
    return $post;
    }
    add_filter('thematic_post', 'childtheme_image_post');
    
    function childtheme_override_postheader_postmeta(){
    
    //the sound of one hand clapping
    }
    
    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();
    				$counter++; 
    
    				thematic_abovepost(); ?>
    
    				<div class="column <?php if ($counter == 1) { echo 'one'; } else { echo 'two'; $counter = 0; } ?>">
    
    				<div class="clear-fix">
    
    				<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 -->
    				</div><!-- .clear-fix -->
    				</div><!-- .column -->
    
    			<?php 
    
    				thematic_belowpost();
    
    				comments_template();
    
    				if ($count==$thm_insert_position) {
    						get_sidebar('index-insert');
    				}
    				$count = $count + 1;
    		endwhile;
    }
    
    // filter thematic_sidebar() .. no display for the page 'Forum', keep it for the rest
    function remove_sidebar() {
    // We test if we are on the page 'Forum'
    if (is_home()) {
    // Yes, we are .. now we switch off the sidebar
    return FALSE;
    } else {
    // we are not .. we leave the switch on
    return TRUE;
    }
    }
    // Connect the filter to thematic_sidebar()
    add_filter('thematic_sidebar', 'remove_sidebar');
    
    //different style sheet for the homepage
    // filter thematic_create_stylesheet to implement your own stylesheets
    function my_stylesheet($content) {
    // We test if we're on home or on your frontpage
    if (is_home() || is_front_page()) {
    // yes, we are .. now let's load the 3c-fixed layout
    $content = "\t";
    $content .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
    $content .= get_bloginfo('stylesheet_directory') . "/style-home.css";
    $content .= "\" />";
    $content .= "\n\n";
    } else {
    // we are not .. let's load the 2c-r-fixed layout
    $content = "\t";
    $content .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
    $content .= get_bloginfo('stylesheet_directory') . "/style.css";
    $content .= "\" />";
    $content .= "\n\n";
    }
    // $content will be handed back to thematic_create_stylesheet
    return $content;
    }
    // connect the filter to thematic_create_stylesheet
    add_filter ('thematic_create_stylesheet', 'my_stylesheet');
    //end different style sheet for the homepage

    getting late here, so i'm going to bed. good luck.

    Posted 8 years ago #
  14. mrmikeman
    Member

    halg thank you so much it works! i cant thank you enough for so much of your time helping me. im not sure i ever would have got it :(
    Take care!

    Posted 8 years ago #
  15. mrmikeman
    Member

    Helga, uhggg. im back again im sorry, i was trying to make another general layout with the post thumbs, i got the 3 columns and i thought by repeating the steps here i would be able to do it without much of a problem, i dont understand either because for a secong i had the post thumbs displaying then i messed up, try to go back and then their not there, i must have not made the right back up...
    you probably hate me by now but if you would consider helping me yet again i would as always, greatly appreciate it

    This is my new link for the three column,
    http://ocixx.com/nb

    i wanted to make a three column post thumb, with the sidebar inplace,(skinnier) than default, and i got the most of it, now im try to replace the post content with the thumbnail, i think i have to specify the thumb width this time wont i, sense these columns are not any of the defaults?

    :( thanks

    Posted 8 years ago #
  16. why can't you just re-use the code above? i don't see why the markup would be any different. from there you can change the CSS.

    Posted 8 years ago #
  17. mrmikeman
    Member

    oh well i was actually trying to re do it again on a fresh thing so i could comment each section of code to label it so i can keep track of what it is but i was stupid at first and didnt make the comments as i got the code.. so now i feel all unorganized and feel like i have messy code :-/ any advice ? also dont know how id start with adding another column with css, the way i made it three columns was copying the code from the same site i got it from before, but its three column part..
    http://hardiannazief.com/12/create-custom-posts-layout-in-home-page-thematic-child-theme/

    Posted 8 years ago #
  18. huh? if you feel you have messy code, just start from scratch. my code above is half-decently commented. you could start from that. i don't understand what further you are asking.

    Posted 8 years ago #
  19. mrmikeman
    Member

    i dont mean messy code exactly, i just wanted to put a //start //end on the chunks of code, labeling what they do, ill get it though

    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.