timboreader
Member
Posted 2 years ago #
Hi,
I need to find out the post ID for a page *which isn't the current page* and in such a way that I can then find the page's post_status (eg 'publish', 'draft').
This is so that I can output a notification on the home page depending on whether e.g. the contact page is live or not.
e.g.
IF contact_page_form == 'publish' THEN
display notification
END IF
Thanks
Tim
<?php
$args=array(
'name' => 'About',
'post_type' => 'page',
'post_status' => 'any',
'posts_per_page' => 1,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
if ($my_query->posts[0]->post_status == 'publish' ) {
echo 'we are good to go!';
}
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>
timboreader
Member
Posted 2 years ago #
Thanks MichaelH, that's just what I was after.
Tim