WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have added custom metaboxes into the wp-admin page and post editors. There is a metabox with the ability to enter in a person's first name (ex. "John") and last name (ex. "Doe").

I want to set that particular post's/page's title to the combined values of those form entries (ex. "John Doe") without having to enter it in the top page/post title bar. This would, thus allow the post/page to behave like a contact card. Preferably, I would like this to work with permalinks too.

I must include any non-native and new code into the functions.php file of my child theme only.

For Reference: I am using the Genesis Framework.

Any suggestions?

share|improve this question

migrated from stackoverflow.com May 29 '12 at 5:06

This question came from our site for professional and enthusiast programmers.

The metabox could be saving info anywhere in the Database. Is this metabox something you have coded together or something that is a part of Genesis? – Brian May 28 '12 at 2:53
I have coded it myself with the help of Bill Erickson's custom metabox post. I am not sure where the info is being saved. I assume it uses the add_meta_box() and add_post_meta() functions. You might check the init.php file that is from Bill Erickson. – A. Tate Barber May 28 '12 at 3:48

Simply filter the_title to replace/append the post title with this post custom meta data.

I assume that you already know how to query your post custom meta data, and as such, that querying will be outside the scope of this answer. Let's assume that you've queried the meta data, as $post_author_fname and $post_author_lname, and that you want to append these names to the beginning of the post title:

function wpse53575_filter_the_title( $title ) {
    // Query post metadata here
    $post_author_fname = '';
    $post_author_lname = '';
    // Concatenate:
    $post_author name = trim( $post_author_fname . ' ' . $post_author_lname );
    // If the name is not an empty string,
    // append it to the post title
    $new_title = ( '' != $post_author_name ? $post_author_name . ': ' . $title ? $title );
    // return the result
    return $new_title;
add_filter( 'the_title', 'wpse53575_filter_the_title' );
share|improve this answer

This does not solve your permalinks issue, but there is a built-in filter for tweaking the titles before being displayed. It is used in the core to add the 'Protected:' or 'Private:' in the title.

Setup the filters with

add_filter( 'protected_title_format', 'your_title_function' );

add_filter( 'private_title_format', 'your_title_function' );

There is a great post that can be modified for your purposes at http://ben.lobaugh.net/blog/20041/wordpress-how-to-remove-protected-and-private-from-post-titles

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.