ThemeShaper Forums » Thematic

[closed]

Moving the thematic_post_header using functions.php

(4 posts)
  • Started 5 years ago by Jamie Mitchell
  • Latest reply from Scott
  • This topic is resolved
  1. Jamie Mitchell
    Member

    Howdy all...

    ok, I'v been working on this for a while, but can't quite get it. So time to ask for a little help.

    what i want to do is move the thematic_postheader (or what's inside it like the page title) up out of the main div and in it's own div below the header using the a child theme functions.php.

    I guess it's probably what Themeshaper has done. that looks to be doing the same thing.

    i tried filtering out the thematic_postheader and then putting it back in the thematic_belowheader, but it did not quite work the way i was hoping.

    thanks in advance for any help.

    Posted 5 years ago #
  2. Hey Jamie,

    still can't imagine what you're going to do, but here's some code for your child theme's functions.php:

    function move_title() {
        global $id, $post, $authordata;
        if (is_single() || is_page()) {
            echo ('<h1 class="entry-title">' . get_the_title() . "</h1>\n");
        } elseif (is_404()) {
            echo ('<h1 class="entry-title">' . __('Not Found', 'thematic') . "</h1>\n");
        }
    }
    add_action('thematic_belowheader', 'move_title');

    The function move_title() will put a title into thematic_belowheader(). You still need to add the mentioned DIV.

    The next function will remove the title from is_single, is_page and is_404, add it to your child theme's functions.php:

    function remove_title($posttitle) {
        if (is_single() || is_page()) {
            return '';
        } elseif (is_404()) {
            return '';
        } else {
        		return $posttitle;
        }
    }
    add_filter('thematic_postheader_posttitle', 'remove_title');

    Would be nice if you could drop a link for me to see what you did with this code.

    Cheers,

    Chris

    Posted 5 years ago #
  3. Jamie Mitchell
    Member

    Chris, your the man !

    it worked perfectly.

    as for wrapping the title in a div i just did this...

    function move_title() {
        global $id, $post, $authordata;
        if (is_single() || is_page()) {
            echo ('<div id="page_title">
    <h1 class="entry-title">' . get_the_title() . "</h1></div>\n");
        } elseif (is_404()) {
            echo ('<div id="page_title">
    <h1 class="entry-title">' . __('Not Found', 'thematic') . "</h1></div>\n");
        }
    }
    add_action('thematic_belowheader', 'move_title');

    not sure if that's right adding the div in there, but it works. That way i can give that page_title div a margin auto and width, and the h1 will be inside it, and i can apply padding to that.

    the site i'm building is for a friend, and should be live in a few days, i will post the link up when it's done. You will like it.

    thanks again...J

    Posted 5 years ago #
  4. hi chris, i just used your solution to remove page headers using remove_title, works great thanks.

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.