i'm new to wordpress and i'm trying to create a website. i need display the content of the pages when corresponding menu items are clicked. my page.php contain
<?php while ( have_posts() ) : the_post();
$page_data= $post->ID;
if($page_data=='116') //Home page
{
?>
<center><b><h2>WELCOME TO THE CLINIC!!</h2></b></center>
<?php
}
else{ //for other pages
?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php
the_content();
}
endwhile; ?>
but my content is not displaying. title is showing properly. what is the mistake in the code? please help me.
Try this -
global $post; // if outside the loop
if ( is_home() || is_front_page() ) {
//your code here
} else {
// This is not the home page
}
Reference link - http://codex.wordpress.org/Conditional_Tags
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.