What custom field names does it use?
The field names used are _pagemeta_title, _pagemeta_description and _pagemeta_keywords.
The underscore prefix prevents it from being displayed in the list of custom fields.
How do I output the custom title?
If a custom title is set for a post type, the plugin will automatically hook into the wp_title function to modify the output.
This uses the parameters passed via wp_title and will completely override the title.
You can customise the output further using the pagemeta_title filter, which uses the same parameters plus the original post title value.
In this example we prefix the original title to the custom title.
add_filter( 'pagemeta_title', function( $title, $sep, $seplocation, $original_title ) {
return $original_title . $title;
}, 10, 4 );
Please refer to the Codex for further information on the add_filter.
Why are the meta tags not added to my pages?
This plugin makes use of the wp_head hook action, therefore in order for it to work there must be a call to wp_head in the current theme header file.
More information on this can be found in the WordPress Codex.
Can I modify which fields are shown?
Yes, as of version 1.5 you can modify which fields are used using the pagemeta_fields filter:
add_filter( 'pagemeta_fields', function( $fields ) {
$fields['author'] = 'Author'; // Add a new field.
unset( $fields['keywords'] ); // Remove a default field.
return $fields;
} );
The default fields are ‘title’, ‘description’ and ‘keywords’.
Can I output the meta values?
The page meta values can be output within posts using the [postmeta] shortcode.
Passing through a name attribute will determine which value is returned, for example to output the description value use the following.
[postmeta name="description"]
Name values are determined by the fields set, by default these are ‘title’, ‘description’ and ‘keywords’.
To output meta values in template files, you can make use of the_pagemeta function.
<?php if ( function_exists( 'the_pagemeta' ) ) { the_pagemeta( 'description' ); } ?>
This will output the value, in order to return the value or lookup a specific post ID you can use get_the_pagemeta.
<?php if ( function_exists( 'get_the_pagemeta' ) ) {
$description = get_the_pagemeta( 'description' );
} ?>
<?php if ( function_exists( 'get_the_pagemeta' ) ) {
$description = get_the_pagemeta(
'description', // Page meta value name
123 // Post ID to lookup
);
} ?>
Not that these functions will return the raw values prior to any output manipulation.