How to get current page id and compare it to looped pages inside the same page?

I have a page template named overview.php which inside shows all the pages that are of the same category. As a result all the pages with the same category are printed but so is the current main page,because it is of the same category as well, and I don’t want this to happen. So inside the loop I want to get the ID of every queried page and compare it to current main page ID so that nothing will happen when it is looped.

This is how I query the pages:

$paged = (get_query_var( ‘paged’ )) ? get_query_var( ‘paged’ ) : 1;
$args = array(
‘post_type’ => ‘page’,
‘post_status’ => ‘Published’,
‘category_name’ => ‘Football League’,
‘posts_per_page’ => 12,
‘paged’ => $paged,
);
$arr_posts = new WP_Query( $args );

if ( $arr_posts->have_posts() ) :

while ( $arr_posts->have_posts() ) :
$arr_posts->the_post();
?>

prints something about each page..

endwhile;
wp_pagenavi(
array(
‘query’ => $arr_posts,
)
);
endif;
?>

Read more here:: How to get current page id and compare it to looped pages inside the same page?

Leave a Reply

Your email address will not be published. Required fields are marked *