[wp-hackers] conditional tags not working

Adam Taylor adamjctaylor at gmail.com
Fri Jun 11 23:18:23 UTC 2010


Hi List,

I'm making some modifications to a Thesis theme-based Wordpress site for a
charity and part of that involves a static homepage.  I don't know whether
any/many of you have used Thesis theme before but they provide their own
additional hooks for hooking in functions.  However, the hook for custom
templates is inadequate for my use as it still presumes one would want the
page/post content as well. So, I wanted to check whether I was on the
homepage and then add extra hooks.

So I have a custom_functions.php file that get's include()'d in the
functions.php file of the Thesis theme and in it, amongst other things, is
the following:

function front_page_check() {
 // echo is_front_page();
// wp_reset_query();
// if (is_front_page()) {
 // global $post;
echo( print_r($post->post_type) );
if ( ($post->post_type == 'page') && ($post->post_title == 'Home') ) {
 // if (is_page('23')) {
die( 'moo' );
echo( $user );
 // add_action('thesis_hook_after_headline','custom_homepage');
// remove_action('thesis_hook_after_post','thesis_comments_link');
 }
}

add_action('init','front_page_check');

The various commented out lines were me trying other things - none of which
work. I can only assume I'm doing something stupid but for the life of me I
cannot seem to get any of the conditionals to return true (i.e. the
echo()/die() are never executed (unless I comment the if)). Also my PHP
debugging skills are fairly limited: for example, that echo only seems to
ever return '1' but I assume that's due to it being a post object and not a
string? Did I just miss the memo that says they only work under
*x*circumstance?!

Anyway, any extra insight into the problem or possible solutions would be
most welcome!

Cheers,
Adam

-- 
adamjctaylor at gmail.com
http://www.twitter.com/adamtaylor
http://www.adamjctaylor.com


More information about the wp-hackers mailing list