ThemeShaper Forums » Thematic


Wrapping Post Title and Post Meta in one new Div

(6 posts)
  • Started 8 years ago by AMain
  • Latest reply from AMain
  • This topic is resolved
  1. Ok, I have been tearing my hair out over this one so I've decided to just give in and ask for help.

    What I am try to do is take the Entry-Title div, and Entry-Meta div, and wrap them in a containing div at the top of the post so that I can give them both the same background.

    As an example, you can see here:

    My post title is wrapped in a div created in my functions that looks like this:

    // Places the title of the post in the containing div above the post.
    function childtheme_posttitle($posttitle) {
    return '<div class="posttitlebg">' . $posttitle . '</div>';

    Which is pretty easy. I got the code from one of Ian's post on the hooks and filters. My problem is that I want also put $postmeta inside of the "posttitlebg" div. I can't make a separate function for it or it will just repeat the div.

    What I cant figure out with thematic is how to make nested divs. This is what I want to end up with in terms of hierarchy:

    I've look through pages and pages and I can find ways to move the meta and post data, but none of them seem to contain information about how to wrap them a containing div.

    Any help would be greatly appreciated.

    Posted 8 years ago #
  2. And please excuse the website. I am doing the changes live because I don't have the stuff set up to do a local install at the moment.

    Posted 8 years ago #
  3. theres probably numerous ways to do this, but the first thing that comes to mind is a simple override function for the postheader

    function childtheme_override_postheader()  {
    global $post;
    if ( is_404() || $post->post_type == 'page') {
    $postheader = '<div class="post-header">' . thematic_postheader_posttitle() . "</div>\n";
    } else {
    $postheader = '<div class="post-header">' . thematic_postheader_posttitle() . thematic_postheader_postmeta() . "</div>\n";
    echo apply_filters( 'thematic_postheader', $postheader ); // Filter to override default post header
    }  // end postheader

    style with

    .post-header {

    dont think you need to add two divs... posttitlebg and postinformation

    just use padding at the top of the div.postheader and use one background for that.

    p.s, i'm unable to test this at the moment

    hope this helps

    Posted 8 years ago #
  4. Well, that definitely works for me for now. I realized that I didn't fully explain my goal. In the long run, I want to set it up so that each post has a unique header background. I plan on having a top and bottom drop shadow to complement the one that is currently on the sides, and do that I was going to put a div with the shadow as a background, then a div on top of that with the image for the header so that I could change the image ( which I think I am going to end doing with a post-id and css) without having to mess with the div that has the drop shadow on it, if that makes sense. However, you have definitely helped me with at least a temporary solution, and I greatly appreciate it.

    Posted 8 years ago #
  5. glad it got you on your way. at the top, theres a 'mark as resolved' button. be a big help if you could mark this as resolved as, for this stage, it is resolved.

    with regards to stage 2,
    i can kinda see where you are going with the changeable header images. just a thought, but you could use the wordpress featured image for this. setting the size of the header in functions, then in each post, you can choose the image that will act as the post header. some absolute position for entry-title and entry-meta could place the titles over the top.

    Posted 8 years ago #
  6. I will definitely look into that, I really appreciate the tip! And thanks again for all your help.

    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.