ThemeShaper Forums » Thematic

[closed]

Custom Post Header Question

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

    Under the Title of each post, I want it to say "written on [date] by [author] in [category]" and I want the author and the category to both be links. So I've been hunting through the forums and made a function that basically works the way I want it to but is lacking the categories bit and even then, it seems excessive. Can anybody help me? This is what I have:

    // Add a custom post header
    function childtheme_postheader() {
    global $post;

    if (is_page()) { ?>
    <?php } elseif (is_404()) { ?>
    <h1 class="entry-title">Yikes! Not Found</h1>
    <?php } elseif (is_single()) { ?>
    <h1 class="entry-title"><?php the_title(); ?></h1>
    <div class="entry-meta">
    <span class="meta-sep"><?php _e('Written on ', 'thematic') ?></span>
    <span class="entry-date"><abbr class="published" title="<?php get_the_time('Y-m-d\TH:i:sO'); ?>"><?php the_time('F jS, Y') ?></abbr></span>
    <span class="author vcard"><?php $author = get_the_author(); ?><?php _e('by ', 'thematic') ?><span class="fn n"><?php _e("$author") ?></span></span>
    </div><!-- .entry-meta -->
    <?php } else { ?>
    <h2 class="entry-title">" title="<?php printf(__('Permalink to %s', 'thematic'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title() ?></h2>
    <?php if ($post->post_type == 'post') { // Hide entry meta on searches ?>
    <div class="entry-meta">
    <span class="meta-sep"><?php _e('Written on ', 'thematic') ?></span>
    <span class="entry-date"><abbr class="published" title="<?php get_the_time('Y-m-d\TH:i:sO'); ?>"><?php the_time('F jS, Y') ?></abbr></span>
    <span class="author vcard"><?php $author = get_the_author(); ?><?php _e('by ', 'thematic') ?><span class="fn n"><?php _e("$author") ?></span></span>

    </div><!-- .entry-meta -->
    <?php } ?>
    <?php }
    }
    add_filter ('thematic_postheader', 'childtheme_postheader');

    Posted 3 years ago #
  2. Danieliser
    Member

    I'm on iPhone so I can't test this now but you can use filters like this

    'Function change_description ($value){
    global $post
    return $value . '<span class="date">' . $post->date . '</span>';
    }
    add_filter('thematic_blog_description', 'thematic_header');'

    The filter hooks might not be correct as I can't check ATM and you will need to modify the return to suit your needs or overwrite $value altogether but you don't need to rewrite the whole header.

    Posted 3 years ago #
  3. this should get you started.... as it will at least get the author, date and category into the postmeta:

    function childtheme_override_postheader_postmeta(){
    	    $postmeta = '<div class="entry-meta">';
    	    $postmeta .= thematic_postmeta_authorlink();
    	    $postmeta .= '<span class="meta-sep meta-sep-entry-date"> | </span>';
    	    $postmeta .= thematic_postmeta_entrydate();
    		$postmeta .= '<span class="meta-sep meta-sep-cat"> | </span>';
    	    $postmeta .= thematic_postfooter_postcategory();
    
    	    $postmeta .= "</div><!-- .entry-meta -->\n";
    
    	    return apply_filters('childtheme_override_postmeta',$postmeta);
    	}

    from here you should examine the content-extensions.php file and look at thematic_postmeta_authorlink(), thematic_postmeta_entrydate() and thematic_postfooter_postcategory() as you are probably going to want to write override functions for all of them. i often copy the original function to my child's functions.php, rename the function w/ the corresponding override name and then make the edits I want to see.

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.