This should be so simple, but in this case, it isn't. In the templates/content-page.php of my theme I want the title to display on all pages, except one... the homepage. I have tried various versions of this code, but nothing works.
<?php if ( !is_front_page() || !is_home() ) { ?>
<header class="page-header">
<h1 class="page-title"><?php echo get_the_title(); ?></h1>
</header>
<?php } ?>
First, we don't need to put the echo with the the_title() function. It will echo automatically.
if ( !is_front_page() && is_home() ) {
// Default homepage ( both the front page and the recent posts page){
<header class="page-header">
<h1 class="page-title"><?php the_title(); ?></h1>
</header>
}
Do you really need to do this? I have in my page.php file
<?php get_header();
$p = get_post();
?>
<div id="main">
<div id="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1 class='pageTitle'><?php the_title();?></h1>
<p><?php the_content(__('(more...)')); ?></p>
<hr>
<?php endwhile; endif; ?>
</div>
<?php get_sidebar('Right Sidebar');?>
</div>
<?php get_footer(); ?>
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.