ThemeShaper Forums » Thematic

[closed]

help with functions for child theme

(4 posts)
  • Started 11 years ago by sleahcim
  • Latest reply from sleahcim
  • This topic is not resolved
  1. sleahcim
    Member

    I've been hacking away at the Aether child theme and have been able to shape it into what I want except for one thing: I want the date to show on all posts, including those that "allow comments" have been turned off.

    I've tried several ways to get this to work and cannot figure out what I'm doing wrong.

    Here's the function that contains the relevant php:

    // Change the Postheader
    function junction_postheader() {
    global $post, $authordata,$id;

    //create the edit-link
    $posteditlink .= '<span class="edit-link"><a href="' . get_bloginfo('wpurl') . '/wp-admin/post.php?action=edit&post=' . $id;
    $posteditlink .= '" title="' . __('Edit post', 'thematic') .'">';
    $posteditlink .= __('Edit', 'thematic') . '</span>';

    if (is_single() || is_page()) {
    $posttitle = '<h1 class="entry-title">' . get_the_title() . "</h1>\n";
    $postmeta = '<div class="entry-meta">';
    $postmeta .= '<div class="post-date">';
    $postmeta .= '<span class="post-day">';
    $postmeta .= get_the_time('d');
    $postmeta .= '</span>';
    $postmeta .= '<span class="post-month">';
    $postmeta .= get_the_time('M');
    $postmeta .= '</span>';
    $postmeta .= '<span class="post-year">';
    $postmeta .= get_the_time('Y');
    $postmeta .= '</span>';
    if (current_user_can('edit_posts')) {
    $postmeta .= $posteditlink;
    }
    $postmeta .= "</div><!-- .post-date -->\n";
    $postmeta .= "</div><!-- .entry-meta -->\n";
    } elseif (is_404()) {
    $posttitle = '<h1 class="entry-title">' . __('Not Found', 'thematic') . "</h1>\n";
    } else {
    $posttitle = '<div class="post-title">';
    $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 .= " <span class='readmore'> ... </span> </h2>\n";
    $posttitle .= '</div>';

    $postmeta = '<div class="entry-meta">';
    $postmeta .= '<div class="post-date">';
    $postmeta .= '<span class="post-day">';
    $postmeta .= get_the_time('d');
    $postmeta .= '</span>';
    $postmeta .= '<span class="post-month">';
    $postmeta .= get_the_time('M');
    $postmeta .= '</span>';
    $postmeta .= '<span class="post-year">';
    $postmeta .= get_the_time('Y');
    $postmeta .= '</span>';

    if (comments_open()) {
    $postcommentnumber = get_comments_number();
    if ($postcommentnumber > '1') {
    $postmeta .= ' <span class="comment">';
    $postmeta .= get_comments_number() . __(' Comments', 'thematic') . '
    </span>';
    } elseif ($postcommentnumber == '1') {
    $postmeta .= ' <span class="comment">';
    $postmeta .= get_comments_number() . __(' Comment', 'thematic') . '
    </span>';
    } elseif ($postcommentnumber == '0') {
    $postmeta .= ' <span class="comment">';
    $postmeta .= __('Leave a comment', 'thematic') . '
    </span>';
    }
    } else {
    $postmeta= ' <span class="comment">' . __('Comments closed', 'thematic') .'</span>';
    }
    if (current_user_can('edit_posts')) {
    $postmeta .= $posteditlink;
    }
    $postmeta .= "</div><!-- .post-date -->\n";
    $postmeta .= "</div><!-- .entry-meta -->\n";
    }

    $postheader = $posttitle . $postmeta;

    if ($post->post_type == 'page' || is_404()) {
    $postheader = $posttitle . $postmeta;
    } else {
    $postheader = $posttitle . $postmeta;
    }
    echo apply_filters( 'junction_postheader', $postheader ); // Filter to override default post header
    }
    add_filter ('thematic_postheader', 'junction_postheader'); // Crazy important!

    Any help would be greatly appreciated.

    Posted 11 years ago #
  2. i dont know about the aether child theme... but why take a look at the original thematic function for postheaders (in the thematic/extensions folder). i believe that the default behavior of thematic is to always show the date, so maybe you just need to delete this function from your child theme. you can test that by just commenting out your add_filter line.

    //add_filter ('thematic_postheader', 'junction_postheader'); // Crazy important!

    Posted 11 years ago #
  3. sleahcim
    Member

    Thanks helgatheviking.

    I finally had a chance to get back to this project and tried your suggestion. No go. It was worth a try though. Still looking for an answer if you think of anything.

    Posted 11 years ago #
  4. sleahcim
    Member

    Okay, I finally figured it out. At least for my particular need. I commented out:
    else {
    $postmeta= ' <span class="comment">' . __('Comments closed', 'thematic') .'</span>';
    }

    in the junction_postheader function. This gave me a date in a post that has comments turned off.

    Posted 11 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.