WordPress.org

Ready to get started?Download WordPress

Forums

is_page broken in wp 2.5.1 ? (3 posts)

  1. drakoh
    Member
    Posted 6 years ago #

    <?
    
    function get_the_pa_ges() {
      global $wpdb;
      if ( ! $these_pages = wp_cache_get('these_pages', 'pages') ) {
         $these_pages = $wpdb->get_results('select ID, post_title from '. $wpdb->posts .' where post_status = "publish" and post_type = "page" order by ID');
    
       }
      return $these_pages;
    }
    
    function findPage() {
    	print "<!-- DEBUG ";
    	$all_pages = get_the_pa_ges ();
    	foreach ($all_pages as $thats_all){
    		$the_page_id = $thats_all->ID;
    
    		print $the_page_id;
    
    		if (is_page($the_page_id)) {
    			print " -> YEAH !";
    		}
    		print "\n";
    	}
    	print "-->";
    }
    
    findPage();
    
    ?>

    I put this in my header.php
    and it seems that it can never find the correct page (no YEAH text)

    any ideas what I am doing wrong ?
    Basically I am trying to highlight menu options depending on the page, and all my attempt using is_page failed so far

    thank you for your time !

  2. drakoh
    Member
    Posted 6 years ago #

    Some more infos,

    in my page section of my admin section, I can't see any of my pages, though I can see published (15)

    this could explain why I can't use is_page, they are nowhere to be found, though they are in the db ...

    what's going on ?

  3. drakoh
    Member
    Posted 6 years ago #

    well guys, I found where my problem was coming from ...

    do not name your global variable $page_id ....

Topic Closed

This topic has been closed to new replies.

About this Topic