• Hello,

    I just figured out how to create a static home page for basically a CMS version of a WordPress site. I haven’t figured out how to keep the homepage title from appearing on the page. I just want it to appear on the tab button, not as a section header.

    I do want the section head on the other pages (About Us, Contact Us, etc.). It seems like it has something to do with the page.php file, but wouldn’t that remove the section title from all of my static pages? Is this something to do with the theme I am using?

    You can see a sample of what I’m talking about with this screen shot:
    https://www.antonellasevero.com/test-homepage.jpg

    Would I need to create a completely static homepage outside of the pages functionality?

    Thanks for any suggestions.

    Regards,
    Antonella

Viewing 15 replies - 1 through 15 (of 22 total)
  • You could use an IF statement to prevent WP from showing the page title if the user is seeing a specified page. Like this:

    <?php If (!is_single(’10’)){?>
    <h2><?php the_title(); ?></h2> <?php }?>

    You have to find the “the_title” tag in your single.php file, and enclose it with the text in bold. Also, you would have to adapt the page ID (10) to suit your needs.

    Thread Starter antorera

    (@antorera)

    Thanks for the tip — I will try it out. I was also wondering after doing further research if creating a custom page template and using different templates would work? If so, which would be the better method? I’m getting stuck on the instructions in the codex because some refer to the techniques pre-2.6 for creating a home page as a static page and I don’t know what applies to creating different page templates yet.

    Thanks!
    Antonella

    Thread Starter antorera

    (@antorera)

    I just tried the IF statement, but it didn’t seem to work.

    In the single.php file, the title tag looks like this:

    <h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>

    I changed it as follows, using a page id of 3 for the file I want to modify:

    <?php If (!is_single('3')){?><h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3><?php }?>

    I then uploaded it into the theme folder.

    Am I doing something wrong here?

    Thanks,
    Antonella

    Actually, that will work if you’re loading just that page. Unfortunately, when your blog is called, it references the Main Index Template (index.php). If you want the header to disappear on the front page, though, you’ll need to find the same section header code in index.php and change it to the following:

    <?php if( ! is_front_page()){?><h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3><?php }?>

    With both of those changes applied, you shouldn’t have any problems. Unless, of course, we’ve missed something. In that case, feel free to come back and let us know. ??

    Thread Starter antorera

    (@antorera)

    Hi Eric,

    I tried that as well but is still didn’t work. I don’t suppose I need a page id since it’s the front page?

    Here’s a link to the draft site:
    https://www.antonellasevero.com/joantest/

    Thanks,
    Antonella

    Eric is right. Did you apply his solution to index.php?

    If you did, it should work. Try checking and posting here the html source of the page so we can try to figure this out…

    Thread Starter antorera

    (@antorera)

    Hi,

    Here is the html source of the section on the rendered page:

      <li class="page_item <li class="page_item page-item-3 current_page_item"><a href="https://www.antonellasevero.com/joantest" title="home">home</a></li>
      <li class="page_item page-item-2"><a href="https://www.antonellasevero.com/joantest/informacion/" title="biografía">biografía</a></li>
      <li class="page_item page-item-9"><a href="https://www.antonellasevero.com/joantest/blog/" title="Blog">Blog</a></li>
      </li></ul>

      Here is the source of the index.php file:

      <?php get_header(); ?>
      
      <div id="content">
      
      	<div id="content-left">
      
      <?php if (have_posts()) : ?>
      
      		<?php while (have_posts()) : the_post(); ?>
      
      			<div class="box-left" id="post-<?php the_ID(); ?>">
      
      				<?php If (!is_front_page()){?><h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3><?php }?>
      				<div class="meta">
      					<span class="meta-date"><?php the_time('l, F jS, Y'); ?></span> |
      					<span class="meta-categories"><?php the_category(', '); ?></span> |
      					<span class="meta-comments"><?php comments_popup_link(__('No Comments'), __('1 Comment'), __('% Comments')); ?></span>
      				</div>
      
      				<?php the_content(__('&rsaquo; Continue reading')); ?>
      
      				<?php the_tags('<p class="tags">Tags: ', ', ', '</p>'); ?>
      
      				<div class="clear"></div></div>
      
      		<?php endwhile; ?>
      
      		<div class="box-left navigation">
      
              	<?php next_posts_link('&laquo; Previous Entries') ?> <?php previous_posts_link('Next Entries &raquo;') ?>
      
      		</div>
      
      		<?php else : ?>
      
      		<div class="box-left">
      
      			<h3>Not found!</h3>
      			<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
      			<?php include (TEMPLATEPATH . "/searchform.php"); ?>
      
      		</div>
      
      <?php endif; ?>
      
      	  </div><!-- end content-left -->
      
      	  <?php get_sidebar(); ?>
      
      	  <div class="clear"></div>
      
      </div><!-- end content -->
      
      <?php get_footer(); ?>

      Here is the source of the single.php file:

      <?php get_header(); ?>
      
      	<div id="content">
      
      		<div id="content-left">
      
      <?php if (have_posts()) : ?>
      
      		<?php while (have_posts()) : the_post(); ?>
      
      			<div class="box-left" id="post-<?php the_ID(); ?>">
      
      				<?php If (!is_single('3')){?><h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3><?php }?>
      				<div class="meta">
      					<span class="meta-date"><?php the_time('l, F jS, Y'); ?></span> |
      					<span class="meta-categories"><?php the_category(', '); ?></span>
      				</div>
      
      				<?php the_content(); ?>
      
      				<?php the_tags('<p class="tags">Tags: ', ', ', '</p>'); ?>
      
      			<div class="clear"></div></div>
      
      			<?php comments_template(); ?>
      
      		<?php endwhile; ?>
      
      		<?php else : ?>
      
      		<div class="box-left">
      
      			<h3>Not found!</h3>
      			<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
      			<?php include (TEMPLATEPATH . "/searchform.php"); ?>
      
      		</div>
      
      <?php endif; ?>
      
      	  </div><!-- end content-left -->
      
      	  <?php get_sidebar(); ?>
      
      	  <div class="clear"></div>
      
      </div><!-- end content -->
      
      <?php get_footer(); ?>

      Let me know if you needed something else to see.

      Thanks so much!
      Antonella

    Antonella,

    The only other change I’d recommend is checking is_home in index.php.

    Change
    <?php if( ! is_front_page()){?><h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3><?php }?>
    To:

    <?php if(is_front_page() || is_home()){?>
       <?php } else { ?>
       <h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
    <?php }?>

    In index.php and let me know if that fixed the problem. If not, then something else is going on …

    This code will check if the user is on the front page or the home page (which are both the same in your case). If they are on either, then it will skip displaying the title. If they aren’t on either page, then it will display the title.

    Thread Starter antorera

    (@antorera)

    Hi Eric,

    It half-worked! The title is still appearing on the static home page but it has disappeared on the Blog page. I do have the static page set up as home page and the blog for recent posts, so I’m not sure what’s going wrong here. Any ideas?

    The logic above did make more sense to me because before it didn’t seem to look for something and perform an action either way.

    Here’s the link again: https://www.antonellasevero.com/joantest/

    Thanks!
    Antonella

    Antonella,

    Try replacing

    <?php if(is_front_page() || is_home()){?>
       <?php } else { ?>
       <h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
    <?php }?>

    With

    <?php if(is_home()){?>
       <?php } else { ?>
       <h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
    <?php }?>
    Thread Starter antorera

    (@antorera)

    Hi,

    Unfortunately this didn’t work either. I actually spent the day testing and retesting before posting back. I even deleted the theme and started over, but I’m still having the same problems.

    The title is disappearing from the Blog section but not the home page. It seems that the code is correct, but there is something conflicting somewhere, so that the blog page is still being read as the home page. Is this possible? I tried testing on different pages (single.php, page.php, index.php). Is there some other page I should be revising?

    I am new to WordPress and would love to use it to build CMS sites and have learned so much in the last few days. I really appreciate all the help you’ve given, and sorry it’s taking so long to get this resolved!

    thanks,
    Antonella

    Antonella,

    Contact me ‘offline’ and I’ll take a look at your theme. I’m wondering if maybe we’re just missing something by talking in the forum. My email is eric [at] eamann [dot] com.

    Thread Starter antorera

    (@antorera)

    I figured it out!!! I started from scratch on a different theme and tested one element at a time. I got it to work and then tried it on the theme I wanted (demar), and with just a variation, also got it to work.

    The only changes required are in the page.php file (no changes to the index.php or single.php).

    If the page.php file has a title tag like this:
    <h2><?php the_title(); ?></h2>

    replace it with this:

    <?php if( ! is_front_page()){?>
    <h2><?php the_title(); ?></h2><?php }?>

    If the page.php file has a title tag that includes a permalink reference like this:
    <h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>

    replace it with this:
    <?php if( ! is_front_page()){?><h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3><?php }?>

    Thank you so much for your help and getting me on my way!
    Antonella

    Thread Starter antorera

    (@antorera)

    Somehow the code function didn’t work in my previous post so I will repost that section for clarity:

    If the page.php file has a title tag like this:

    <h2><?php the_title(); ?></h2>

    replace it with:

    <?php if( ! is_front_page()){?>
    <h2><?php the_title(); ?></h2><?php }?>

    If the page.php file has a title tag that includes a permalink reference like this:

    <h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>

    replace it with this:

    <?php if( ! is_front_page()){?><h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3><?php }?>

    That’s what we lost in the long forum post … I thought we had been working with page.php and just now noticed we had been working instead with single.php. My mistake for not catching that the first time around.

    I’m glad it’s working for you now!

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘How to remove double titles’ is closed to new replies.