Jump to content
TNG Community
Sign in to follow this  
Marcus Zurhorst

How to overwrite the WP title with the TNG title

Recommended Posts

Marcus Zurhorst

I think that has been asked before, and I also saw some hints that I might be related to the particular theme.

From what I can see, the "hack" should be rather simple and straight-forward. I would assume that it would work in a lot of different themes.

Somewhere in the theme is a file which contains the initial meta data of the HTML output. A typical name would be header.php or similar. This file will contain the title tag. Maybe with some more PHP magic, but it should be identifyable.

What you need to do is this:

1) find out page ID for your TNG page in WordPress (e.g. by hoovering over the link to the page in the admin backend; in the example below, it is 332)

2) put a condition around the title tag to only display it when the page is NOT the TNG page.

<!DOCTYPE html>
     <?php if ( !is_page( 332 )) { ?>
         <title><?php wp_title( '|', true, 'right' ); ?></title>
     <?php } ?>
   <body class="page page-id-332 page-template">

I assume this will work for many themes. Only keep in mind to create a child theme instead of altering the original file.




Share this post

Link to post
Share on other sites
Marcus Zurhorst

Hello all,

after a long while, I found some time to fix my website.  Now that the basic functionality is restored, I saw that my SEO friendly TNG titles were not displayed. When I was crawling though the header.php file in my WP theme, I was amazed when I did not find identify the wp_title() call anymore.

So, doing some research, I found the explanation for this:   Back in December 2014, WordPress 4.1 was released with a new theme support option for page titles. Basically all themes are supporting this nowadays. Therefore, the <title> tag is spilled into the HTML code through the central wp_head() call in the header.php file of these themes.

I found the following workaround:

  1. creating a child theme in WordPress    (anyways a good idea when tweaking the scripts and adding CSS.)
  2. unregistering the theme support for the title tags in the functions.php file of the child theme.  This is executed after the functions.php of the parent theme, where the theme author registered the theme support ;)  (see code sniplet #1)
  3. copying the header.php file from the parent to the child theme folder.
  4. adding the explict call to the older wp_title() function into the header.php in the child theme  (this is the "old" (=pre WP 4.1) way of doing it)  (code sniplet #2)

The code sniplets are shown below.

One more word regarding the different WP-TNG-integration methods:

  1. Integration Plugin: make the wp_title() call conditional as explained in the post above.   (if (!is_page(nnn)) ...   )
  2. Cees Kloosterman method: instead of the if-clause, I use two differnt header files.   header.php  (for WordPress, with the wp_title() call) and the header-tng.php file for the TNG pages. On this one, I did not add the call to the wp_title() function.


All in all again pretty simple. Let's only hope that WordPress does not deprecate the direct call to the wp_title() function.  ;)






code sniplet #1:   add this to the functions.php of the child theme

add_action( 'after_setup_theme', 'child_after_setup_theme', 11 ); 
// Parent theme uses the default priority of 10, so
// use a priority of 11 to load after the parent theme.

function child_after_setup_theme()


code sniplet #2:   add this to the header.php of the child theme

// code sniplet 2a) for TNG integration plugin
<?php if ( !is_page( nnn )) { ?>
     <title><?php wp_title( '|', true, 'right' ); ?></title>
<?php } ?>

// code sniplet 2b)  for Cees Kloosterman integration method
<title><?php wp_title( '|', true, 'right' ); ?></title>



Share this post

Link to post
Share on other sites


I spent some time on this yesterday struggling to find out why the TNG titles had disappeared, and came to a little bit different solution.

If you have the All in One SEO Pack installed, you can use that to tell WordPress to not put the Title on the Genealogy page.

Then I  make a TNG Mod to make the changes needed to the theme files to effect the change (since for Suffusion it has to go in a WordPress core file)

In Atahualpa it goes in header.php as you describe, but for Suffusion 4.4.9 it goes in general-template.php

And you can use this


with the TNG-WordPress plugin to evaluate what you call nnn to determine the pageID that you have set the plugin to work on, so

if (!( get_the_ID() == get_option('mbtng_wordpress_page'))) {
		echo '<title>' . wp_get_document_title() . '</title>' . "\n";

for example.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this