• I run into a weird bug on 2.3. I’m using a static home page (“Home”), and then another page (“Archive”) to dislpay the blog. I have no way to target only the “Archive” page with conditional comments. is_home() will return true for both the front page and the posts page (“Home” and “Archive” in my case). is_page(‘Archive’) doesn’t work. I also tried the is_frontpage() plugin but it doesn’t return true for any page.

    Am I doing something wrong or is this a problem that appeared after “fixing” the behavior of is_home from previous versions? Is anyone else having this problem?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I have the same problem with a static index.php page and the blog in /blog/index.php. is_home is returning positive in both cases: see https://af.awardspace.co.uk/

    What is the best way to differentiate between these two pages?

    HB

    maybe try using is_page() with the id of the page you have as the static homepage in the brackets?

    I have the same problem as well and here is how I got around what I think is a bug. (See thread.)

    I have a WP Page called Blog and a corresponding template Blog.php with a template name of TmplBlog. Be sure that the template name is different from the name of the page or other weirdness (bugs?) will crop up with navigation links.

    I created the following conditional functions in my functions.php file:

    function get_page_id($page_title, $output = OBJECT) {
    	global $wpdb;
    	$page_title = $wpdb->escape($page_title);
    	$page = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$page_title' AND post_type='page'");
    	if ( $page )
    		return $page;
    
    	return NULL;
    }
    
    function is_blog() {
    	global $wp_query;
    	global $cached_page_id;
    	$blog_page_id = get_page_id('Blog');
    	if ( is_category() || is_day() || is_month() || is_year() || is_paged() || is_single() )
    		return true;
    	if ( isset($cached_page_id) && ($blog_page_id == $cached_page_id ))
    		return true;
    	if ( is_page('Blog') )
    		return true;
    
    	return false;
    }

    I then make sure that in any logic a call to is_blog() happens prior to any is_home calls. Note that the cached_page_id business is there since the page_id seems to be reset when I run custom queries on the page. So I cache it first thing on my TmplBlog tempalte.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Conditional tags on 2.3 when using a static home page’ is closed to new replies.