ThemeShaper Forums » Thematic

how to parse what type of page i'm on

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

    i'm trying to do something similar. there's a bunch of stuff i want to insert using thematic_belowheader(), depending on what type of page i'm on. unfortunately, i think i'll be using these for section headings (they have to be images because of the font), so the conditional tree will actually be pretty big. seems like a stupid way of doing it, but i can't come up with anything better.

    anyway, as a result, i'd really like to have a robust "what type of page" function, that i can throw at anything. right now i'm just trying to parse these page types:

    • front page
    • post
    • page
    • blog/multipost/archive/etc

    this is what i've got so far:

    function my_belowheader() {
    // Get $post if you're inside a function
    global $post;
    
    	if ( is_front_page() ) {
    		$content = 'front page';
    	} elseif ( is_page() ) {
    		$content = 'a page';
    	} elseif ( is_post() ) {
    		$content = 'a post';
    	} else {
    		$content = 'multipage';
    	}
    
    	echo $content;
    }
    add_filter('thematic_belowheader','my_belowheader');

    it works on pages & front page, but on posts or multipost pages it give me a undefined function is_post() error.

    can anyone help me on this?

    i'm also wondering if there's a better place to be doing page parsing than in thematic_belowheader()??

    thanks.

    Posted 4 years ago #
  2. snack
    Member

    update: error was coming from the fact that there's no such thing as is_post(). i have no idea where i got that.

    here's what i have now:

    if ( is_front_page() ) {
    		$content = 'front page';
    	} elseif ( is_page() ) {
    		$content = 'a page';
    	} elseif ( is_single() ) {
    		$content = 'a post';
    	} elseif ( is_404() ) {
    		$content = '404';
    	} elseif ( is_home() || is_archive() || is_category() ) {
    		$content = 'multipost';
    	} else {
    		$content = 'something else';
    	}

    i'm still wondering:
    is thematic_belowheader() the best place to do this? is this the best way?

    and most importantly -- are there other multipost categories that i left out???

    thanks.

    Posted 4 years ago #
  3. Hi,

    .. with is_archive() you cover pretty much everything that was left over. You could split it up into is_day(), is_month(), is_year(), is_tag, or is_category() if needed.

    As long as you remember that the area thematic_belowheader() has the same dimensions like the header :-)

    Cheers,

    Chris

    Posted 4 years ago #

RSS feed for this topic

Reply

You must log in to post.