Software Developer

Add Spaces Between Names and Dates in WP Family Tree

PROBLEM: The WP Family Tree plugin for WordPress displays the person’s data in an HTML table on the single family member posts. This data includes the person’s name, birth date, death date, parents’ and siblings’ names. The table element is okay for data such as this. But my problem is that I pull the first few lines of that data as the description meta tag. Actually, I use ‘the excerpt’ as the description meta tag in the head, which is the same thing — it’s the first several lines of this data. This is good, not only for search engine ranking, but simply so that people researching the same family history can find your pages. But since the person’s information is displayed in table cells, there are no separating spaces between the cells.

This means that when you have a family member who’s data that looks like this:

wp-family-tree plugin table data example

It will be pulled like this, and end up looking like this as an excerpt:

Franklin J. McClaskeyBorn: 1874-11-07Father: Isaac O McClaskeyMother: 
Laura McClaskeyChildren: Franklin John McClaskey Jr. , Laura Sarah 
Lee McClaskey , Benjamin G. McClaskey , Alvin E....

See how the date and parents’ names run into each other. To fix this, I add some spaces between the table data. This makes for better meta descriptions and better excerpts for people in your WP Family Tree. Here’s how to do it.

FILE TO EDIT: wp-content/plugins/wp-family-tree/class.node.php
PURPOSE: Add spaces between table data, for better descriptions pulled in excerpts for head meta description.

Add a space after the birth date

1. Find this code, which should be about line 79:

$html .= '<td style="vertical-align:bottom">Born: '.$this->born.'</td>';

2. Change that line to this:

$html .= '<td style="vertical-align:bottom">Born: '.$this->born.' </td>';

Add a space after the death date

1. Find this code, which should be about line 81:

$html .= '<td style="vertical-align:bottom">Died: '.	$this->died.'</td>';	

2. Change that line to this:

$html .= '<td style="vertical-align:bottom">Died: '.	$this->died.' </td>';	

Add a space after the father’s name

1. Find this code, which should be about line 88:

$html .= '<a href="'.$this->url_father.'">'.$this->name_father.'</a>';

2. Change that line to this:

$html .= '<a href="'.$this->url_father.'">'.$this->name_father.'</a> ';

3. Find this code, which should be about line 90:

$html .= 'Unspecified';

4. Change that line to this:

$html .= 'Unspecified ';

Add a space after the mother’s name

1. Find this code, which should be about line 95:

$html .= '<a href="'.$this->url_mother.'">'.$this->name_mother.'</a>';

2. Change that line to this:

$html .= '<a href="'.$this->url_mother.'">'.$this->name_mother.'</a> ';

3. Find this code, which should be about line 97:

$html .= 'Unspecified';

4. Change that line to this:

$html .= 'Unspecified ';

Add a space after the children’s name

1. Find this code, which should be about line 109:

$html .= '<a href="'.$the_family[$child]->url.'">'.$the_family[$child]->name.'</a>';

2. Change that line to this:

$html .= '<a href="'.$the_family[$child]->url.'">'.$the_family[$child]->name.'</a> ';

3. Find this code, which should be about line 109:

$html .= 'none';

4. Change that line to this:

$html .= 'none ';

Add a space after the siblings’ name

1. Find this code, which should be about line 124:

$html .= '<a href="'.$the_family[$sibling]->url.'">'.$the_family[$sibling]->name.'</a>';

2. Change that line to this:

$html .= '<a href="'.$the_family[$sibling]->url.'">'.$the_family[$sibling]->name.'</a> ';

3. Find this code, which should be about line 127:

$html .= 'none';

4. Change that line to this:

$html .= 'none ';

NOTE: This code modifies the plugin core. If you do this, keep a change log of your changes. You’ll have to make these changes again after upgrading the WP Family Tree plugin to a new version. As always, modifications made to the plugin core will be overridden when you upgrade the plugin. The extra work is worth it to me, for a plugin that does what I want it to do. I keep a simple changelog. Re-doing all my customizations after an upgrade takes me about 2 minutes.

By

We've One Response

  1. November 24th, 2012 at 5:21 pm

    Thank you, beautiful Isabel! I am just customizing the genealogy tree on my family site based on the WP family tree plugin. Your post was very useful for me. God bless you.

    avatar

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]