I am trying to get my current page id and title for reference but before I output them I override the global $post in my header.
This is my code:
<?php
global $post;
$current_page_id = $post->ID;
echo $current_page_id;
?>
This is my header code:
<div id="slider" class="nivoSlider">
<?php
$slides = get_posts( array( 'post_type' => 'slide' ) );
foreach( $slides as $post ): setup_postdata( $post );
$slide_url = get_slide_url();
$slide_thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "slide" );
?><a href="<?php echo $slide_url; ?>" title="<?php the_title_attribute(); ?>"><img src="<?php echo $slide_thumbnail[0]; ?>" /></a><?php
endforeach;
?>
</div>
It returns the last used post but I want my current page post.
I have created a custom meta box for post type product to select a page to display on. I am trying to get posts of type product and of the current page id to output onto the screen.
Thanks
use ‘wp_reset_query’ function before post id retrieving for this: