ThemeShaper Forums » Thematic

Add Custom Field & Comments to PostHeader ?

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

    Hi,
    I am having trouble adding a custom "sub-title" field to my postheader. I was able to do so cobbling together examples from an older example on these forums but that example took out the author link and then I couldn't get that back... So needless to say I have been chasing my tail on this and any help/code adding a custom field and comments to the postheader would be much appreciated...
    Thanks!

    Posted 2 years ago #
  2. Derker
    Member

    this older-style code is working (but could it be slowing down the site?) I would like to figure out how to keep the functionality but in the new mode.... any thoughts?

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

    if (is_page()) { ?>
    <h1 class="entry-title"><?php the_title(); ?></h1>
    <?php } elseif (is_404()) { ?>
    <h1 class="entry-title">Yikes! Not Found</h1>
    <?php } elseif (is_single()) { ?>
    <h1 class="entry-title"><?php the_title(); ?></h1>
    <h2 class="sub-title"><?php the_meta(); ?></h2>
    <div class="entry-meta">
    <span class="author vcard"><?php _e('By ', 'thematic') ?><span class="fn n"><?php $author = the_author_posts_link(); ?></span></span>
    <span class="meta-sep">|</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="meta-sep">|</span>
    <span class="email-this"><?php if(function_exists('wp_email')) { email_link(); } ?> </span>

    <?php edit_post_link(__('Edit', 'thematic'), "\t\t\t\t\t<span class=\"meta-sep\">|</span>\n<span class=\"edit-link\">", "</span>\t\t\t\t\t"); ?>
    </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 ?>
    <h2 class="sub-title"><?php the_meta(); ?></h2>
    <div class="entry-meta">
    <span class="author vcard"><?php _e('By ', 'thematic') ?><span class="fn n"><?php $author = the_author_posts_link(); ?></span></span>
    <span class="meta-sep">|</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="meta-sep">|</span>
    <span class="comments-link"><?php comments_popup_link(__('Comment', 'thematic'), __('1 Comment', 'thematic'), __('% Comments', 'thematic')) ?></span>

    <span class="meta-sep">|</span>
    <span class="email-this"><?php if(function_exists('wp_email')) { email_link(); } ?> </span>

    <?php edit_post_link(__('Edit', 'thematic'), "\t\t\t\t\t<span class=\"meta-sep\">|</span>\n<span class=\"edit-link\">", "</span>\t\t\t\t\t"); ?>
    </div><!-- .entry-meta -->
    <?php } ?>
    <?php }
    }
    add_filter ('thematic_postheader', 'childtheme_postheader');

    Posted 2 years ago #
  3. Hi,

    this code can't work .. a filter means that you change / delete / extend / replace a string or array or whatever ..

    ...let say we would provide the following function in Thematic:

    function any_text() {
        $content = 'This is my blog';
        echo apply_filters('any_text', $content);
    }

    and you want to extend it:

    function my_text($content) {
        $content .= ' called "' . get_bloginfo('name') . '"';
        return $content;
    }
    add_filter('any_text', 'my_text'};

    As soon as you echo a string or call a function that echoes a string inside your fiter function this will echo the whole thing before the original function.

    Chris

    Posted 2 years ago #

RSS feed for this topic

Reply

You must log in to post.