ThemeShaper Forums » Thematic

[closed]

3.1 Post Formats in Thematic Child Themes

(4 posts)
  • Started 8 years ago by notlaura
  • Latest reply from notlaura
  • This topic is resolved
  1. I was reading another thread,Strategy, Function for WP 3.1 Post Formats in Thematic, but thought support questions would be better suited to a new topic.

    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? How have you used post formats in Thematic?

    Posted 8 years ago #
  2. haven't really dabbled in post formats yet. they are so new, but i do want to dig in eventually.

    Posted 8 years ago #
  3. 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!

    Posted 8 years ago #
  4. OK, figured this out. See this thread about it: http://forums.themeshaper.com/topic/how-to-add-post-format-classes-to-thematics-body-classes#post-20728

    Posted 7 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.