Support » Fixing WordPress » Post Formats in Thematic Child

  • Resolved Lara Schenck

    (@notlaura)


    Following the format from this post, I’ve been testing post formats in a Thematic child theme and added this to functions.php:

    // Enable a few post formats
    add_theme_support( 'post-formats', array( 'gallery', 'image', 'link') );
    
    // Post formats function
    function wpfolio_post_formats() {
    
        if ( has_post_format( 'gallery' )) {
         echo '<div class="gallery-format">';
            echo the_content();
         echo '</div>';
        } else if ( has_post_format( 'image' )) {
         echo '<div class="image-format">';
            echo the_content();
         echo '</div>';
        } else if ( has_post_format( 'link' )) {
         echo '<div class="link-format">';
            echo the_content();
         echo '</div>';
        }
        ...
        else {
            echo the_content();
        }
    }
    
    add_action('thematic_post', 'wpfolio_post_formats');

    This works but is pretty limited – it seems I can’t style the post header and footer without adding more functions and filters with their own sets of conditions.

    With reference to this post I’ve tried to use the .format-image classes instead by adding them to the stylesheet and replacing my above classes with this:
    echo ‘<div id=”post-<?php post_ID(); ?>” <?php post_class(); ?>’;

    No luck – the style disappears completely. Any ideas?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • I think I narrowed this down to an issue with the post class. I did some echoing and saw that the post format selector (.format-image{}, etc.) appears as it should in post_class() but is not included in thematic_post_class(). I tried removing thematic_post_class() with childtheme_override_post_class() which seemed to work – echoing thematic_post_class() no longer returns anything. Here is the code:

    // remove thematic_post_class to include post format selector in post class
    function childtheme_override_post_class() {
         remove_action('thematic_post_class','thematic_access', 9);
    }
    add_action('init', 'childtheme_override_post_class');
    
    // echo post classes for format testing
    function wpfolio_post_formats() {
    
         global $post;
         $post_id = $post->ID;
    
         $format = get_post_format( $post_id );
    
              if ( has_post_format( 'gallery' )) {
                   echo '<h3>';
                   echo $format . '<hr />';
                   echo '<strong>thematic_post_class: </strong>';
                   echo thematic_post_class();
                   echo '<hr /> <strong>post_class: </strong>';
                   echo post_class();
                   echo '</h3>';
                   echo the_content();
              } else if ( has_post_format( 'image' )) { ...
    }
    
    add_action('thematic_post', 'wpfolio_post_formats');

    Then I replaced the conditional’s content with something like this to see if the styles would work:

    if ( has_post_format( 'video' )) {
         echo '<div id="<?php the_ID(); ?>" <?php post_class() ?>';
         echo the_content();
         echo '</div>';
    } else if { ...

    Nothing happens. I’m thinking thematic_post() may not be the right hook, but it did work with the code from my first post. Any help is greatly appreciated. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post Formats in Thematic Child’ is closed to new replies.