• I have the following loop to add links for sub pages in one of my sections. I now want to add the link so, that if you are already on a page it adds a disabled link, so you can’t click on it again. What I am struggling with now is finding a way to test if the current page’s id is equal to the id of the linked to page. Here is what I have so far, but it doesn’t work like I want it:

    if ($queryObject->have_posts()) {
    	while ($queryObject->have_posts()) {
    		$queryObject->the_post();
    
    		if ( is_page() == the_ID() ) {
    			echo '<li>; the_title(); echo '</li>';
    		} else {
    			echo '<li><a href="'; the_permalink(); echo '">'; the_title(); echo '</a></li>';
    		};
    
    	}
    }

    I have also tried both of the following:

    if ( is_page() == $queryObject->the_post()->ID ) {

    if ( is_page() == $queryObject->post->ID ) {

    Thanks a lot for any help with this!

  • The topic ‘Comparing current page's id to post's page id?’ is closed to new replies.