Hi there,
I'm new to thematic and wordpress, amazed so far at how much I can do easily. But I'm stuck on this one.
I would like site authors to be able to specify an author name for a post other than themselves or another registered user. This name would show up in the post header instead of their username.
I figure the best way to do this is create a custom field "articleauthor" and rewrite the thematic_postheader filter to show the contents of this fielf if it is set, otherwise show the usual username. Pretty simple php.
I followed the tutorial at http://themeshaper.com/filters-wordpress-child-themes/ and got the postheader to say "bacon". I figured from there all I would have to do is copy and paste the contents of function thematic_postheader() over the echo "bacon"; line in my functions.php, then make the required changes to the code.
When I do this, the postheader dissappears entirely (after just a straight copy and paste, before changing any code). Here is the function as it sits in my functions.php:
function childtheme_postheader() {
global $id, $post, $authordata;
// Create $posteditlink
$posteditlink .= '<a href="' . get_bloginfo('wpurl') . '/wp-admin/post.php?action=edit&post=' . $id;
$posteditlink .= '" title="' . __('Edit post', 'thematic') .'">';
$posteditlink .= __('Edit', 'thematic') . '';
$posteditlink = apply_filters('thematic_postheader_posteditlink',$posteditlink);
if (is_single() || is_page()) {
$posttitle = '<h1 class="entry-title">' . get_the_title() . "</h1>\n";
} elseif (is_404()) {
$posttitle = '<h1 class="entry-title">' . __('Not Found', 'thematic') . "</h1>\n";
} else {
$posttitle = '<h2 class="entry-title"><a href="';
$posttitle .= get_permalink();
$posttitle .= '" title="';
$posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
$posttitle .= '" rel="bookmark">';
$posttitle .= get_the_title();
$posttitle .= "</h2>\n";
}
$posttitle = apply_filters('thematic_postheader_posttitle',$posttitle);
$postmeta = '<div class="entry-meta">';
$postmeta .= '<span class="meta-prep meta-prep-author">' . __('By ', 'thematic') . '</span>';
$postmeta .= '<span class="author vcard">'. '<a class="url fn n" href="';
$postmeta .= get_author_link(false, $authordata->ID, $authordata->user_nicename);
$postmeta .= '" title="' . __('View all posts by ', 'thematic') . get_the_author() . '">';
$postmeta .= get_the_author();
$postmeta .= '</span><span class="meta-sep meta-sep-entry-date"> | </span>';
$postmeta .= '<span class="meta-prep meta-prep-entry-date">' . __('Published: ', 'thematic') . '</span>';
$postmeta .= '<span class="entry-date"><abbr class="published" title="';
$postmeta .= get_the_time(thematic_time_title()) . '">';
$postmeta .= get_the_time(thematic_time_display());
$postmeta .= '</abbr></span>';
// Display edit link
if (current_user_can('edit_posts')) {
$postmeta .= ' <span class="meta-sep meta-sep-edit">|</span> ' . '<span class="edit">' . $posteditlink . '</span>';
}
$postmeta .= "</div><!-- .entry-meta -->\n";
$postmeta = apply_filters('thematic_postheader_postmeta',$postmeta);
if ($post->post_type == 'page' || is_404()) {
$postheader = $posttitle;
} else {
$postheader = $posttitle . $postmeta;
}
}
add_filter('thematic_postheader','childtheme_postheader');
What am I doing wrong here?
thanks