WordPress.org

Ready to get started?Download WordPress

Forums

How to remove double titles (23 posts)

  1. antorera
    Member
    Posted 5 years ago #

    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:
    http://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

  2. renato_s
    Member
    Posted 5 years ago #

    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.

  3. antorera
    Member
    Posted 5 years ago #

    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

  4. antorera
    Member
    Posted 5 years ago #

    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

  5. Eric Mann
    Member
    Posted 5 years ago #

    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. :-)

  6. antorera
    Member
    Posted 5 years ago #

    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:
    http://www.antonellasevero.com/joantest/

    Thanks,
    Antonella

  7. renato_s
    Member
    Posted 5 years ago #

    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...

  8. antorera
    Member
    Posted 5 years ago #

    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="http://www.antonellasevero.com/joantest" title="home">home</a></li>
      <li class="page_item page-item-2"><a href="http://www.antonellasevero.com/joantest/informacion/" title="biografĂ­a">biografĂ­a</a></li>
      <li class="page_item page-item-9"><a href="http://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

  9. Eric Mann
    Member
    Posted 5 years ago #

    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.

  10. antorera
    Member
    Posted 5 years ago #

    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: http://www.antonellasevero.com/joantest/

    Thanks!
    Antonella

  11. Eric Mann
    Member
    Posted 5 years ago #

    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 }?>
  12. antorera
    Member
    Posted 5 years ago #

    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

  13. Eric Mann
    Member
    Posted 5 years ago #

    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.

  14. antorera
    Member
    Posted 5 years ago #

    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

  15. antorera
    Member
    Posted 5 years ago #

    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 }?>

  16. Eric Mann
    Member
    Posted 5 years ago #

    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!

  17. chestmclargehuge
    Member
    Posted 5 years ago #

    Hello, I'm after the same thing, deleting double titles. The theme I'm using is Thematic and it doesn't have a page.php. It looks like the php I need to modify might be on the index.php page. I'm not fluent in php. The two pages I'm trying to eliminate the double titles on is "About" and "Contact", http://thedadreport.com/about/

    Here is my index.php code

    <?php get_header(); ?>
    <!-- "You know what I need? I need a drink. There's some ice and stuff back there. Why don't you make us all some old fashioneds? - Tyler Fitzgerald" -->
    
    <div id="contentwrap">
    
      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    	<div class="entry">
    		<h3 <?php if (is_page()) echo 'style="margin-bottom: 20px;" ' ?>class="entrytitle" id="post-<?php the_ID(); ?>"><a title="Article-Link (Permalink)" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> <?php edit_post_link('<img class="editpost" alt="Edit" src="' . get_bloginfo('template_directory') . '/images/edit.gif" />', '', ''); ?></h3>
    		<div class="entrymeta1">
    		<?php
    
    		if (! is_page()) {	// Do not display if we are on a page
    			// Date and author
    			if (is_single()) { $articledate = get_the_time('F j, Y, G:i') . ' Uhr'; } else { $articledate = get_the_time('F j, Y'); }
    			echo '<span class="meta-time">' . $articledate . '</span><span class="meta-category">'; the_category(', '); echo '</span><span class="meta-author"><a title="author" href="'; the_author_url(); echo '">'; the_author(); echo '</a></span>';
    			// Comments link
    			comments_popup_link('<span class="meta-comments">0 comments</span>', '<span class="meta-comments">1 comment</span>', '<span class="meta-comments">% comments</span>');
    
    		} // ! is_page()
    		?>
    		</div> <!-- [entrymeta1] -->
    
    		<div class="entrybody">
    			<?php the_content(__('Read more &raquo;'));?>
    		</div> <!-- [entrybody] -->
    
    		<?php if (is_single()) { ?>
    
    		<div class="entrymeta2">
    		<ul>
    		<?php
    		// *** Trackback URI: only if ping is enabled
    		if ( pings_open() ) { ?>
    			<li><a class="trackback-leftalign" title="Trackback-URL for '<?php the_title() ?>'" href="<?php trackback_url() ?>" rel="nofollow">Trackback-URL</a></li>
    <?php   }
    		?>
    
    		<?php
    		// *** RSS Comments: only if comments are enabled
    		if ( comments_open() ) { ?>
    			<li class="feed-leftalign"><span title="Subscribe to comments feed"><?php comments_rss_link('RSS feed for comments on this post') ?></span></li>
    <?php	}
    		?>
    
    		<?php
    		// *** Tags: only if there is any
    		if ( (function_exists('UTW_ShowTagsForCurrentPost')) ) { ?>
    		    <li class="utwtags"><span title="tags"><?php UTW_ShowTagsForCurrentPost("commalist") ?></span></li>
    <?php   }
    		?>
    		</ul>
    
    		</div> <!-- [entrymeta2] -->
    
    		<?php comments_template(); // Get wp-comments.php template ?>
    
    		<?php } // is_single() ?>
    
        <!--
    	<?php trackback_rdf(); ?>
    	-->
      </div> <!-- [entry] -->
    
      <?php endwhile; else: ?>
      <p><?php _e('No Entries found.'); ?></p>
      <?php endif; ?>
      <p><?php posts_nav_link(' — ', __('&laquo; Previous Page'), __('Next Page &raquo;')); ?></p>
    
    </div> <!-- [contentwrap] -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  18. chestmclargehuge
    Member
    Posted 5 years ago #

    Okay, the code to make it happen is in here cuz when deleted it did what I wanted, however it also took out the title of my blog post. I wanna keep the blog post title but kill the double title on the static pages like "About" and "Contact". Thanks. E

    <h3 <?php if (is_page()) echo 'style="margin-bottom: 20px;" ' ?>class="entrytitle" id="post-<?php the_ID(); ?>"><a title="Article-Link (Permalink)" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> <?php edit_post_link('<img class="editpost" alt="Edit" src="' . get_bloginfo('template_directory') . '/images/edit.gif" />', '', ''); ?></h3>

  19. davesgonebananas
    Member
    Posted 5 years ago #

    Replace the line that starts

    <h3 <?php if (is_page()) echo 's...

    with

    if (!is_page()) {
        <h3 <?php if (is_page()) echo 's...
    }

    This will only display the article header if it's not a static page (i.e. it's a blog post).

  20. chestmclargehuge
    Member
    Posted 5 years ago #

    Dave, As alluded to I'm not any good at php. I see where you put the "if" in front of the h3 but where do you insert the "}" at the end?
    I tried it after </h3> but it didn't work that way. Thanks man.

  21. davesgonebananas
    Member
    Posted 5 years ago #

    That's my fault as I ommitted the <?php tags from my original post. Here is the code you need in context.

    <div class="entry">
        <?php if (!is_page()) { ?>
            <h3 <?php if (is_page()) echo 'style="margin-bottom: 20px;" ' ?>class="entrytitle" id="post-<?php the_ID(); ?>"><a title="Article-Link (Permalink)" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> <?php edit_post_link('<img class="editpost" alt="Edit" src="' . get_bloginfo('template_directory') . '/images/edit.gif" />', '', ''); ?></h3>
        <?php } ?>
    <div class="entrymeta1">
  22. chestmclargehuge
    Member
    Posted 5 years ago #

    My mistake above, the theme code shown is what I'm using but is not from Thematic, sorry, I have too many WP's under construction. So apologies to Ian at Thematic and many thanks to davesgonebananas.

  23. ryanpezzotti
    Member
    Posted 5 years ago #

    Hello,

    My website is http://www.seowhitehats.com. I have duplicate title tags on all of my pages. Can any give me a recommendation on how to resolve this issue. I am not sure where to locate the piece of code to remove this?

    Thanks,

    Anthony

Topic Closed

This topic has been closed to new replies.

About this Topic