Plugin Author
Steve
(@stvwhtly)
Hi,
Although unfamiliar with the WordPress SEO plugin in question, I have spotted that it makes use of a number of filters therefore it should be possible to do ask you require.
Something like this may work to output the subheading as the meta description if one is set, otherwise use the default.
add_filter( 'wpseo_metadesc', function( $description ) {
global $post;
if ( $subheading = get_post_meta( $post->ID, '_subheading', true ) ) {
return $subheading;
}
return $description;
} );
Note that I’ve not testing that it actually works.
You could try adding this to your theme functions.php file and see if it makes any difference.
Reference: See line 869 http://plugins.trac.wordpress.org/browser/wordpress-seo/trunk/frontend/class-frontend.php
Hope this points you in the right direction.
This is causing an error in Google Chrome when I try to access the back end of the site:
Server error
The website encountered an error while retrieving http://www.beyondtheninetyminutes.com/wp-admin/theme-editor.php?file=functions.php&theme=Advanced-Newspaper&scrollto=400&updated=true. It may be down for maintenance or configured incorrectly.
Here are some suggestions:
Reload this webpage later.
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
Once I remove that coding, the site is working properly.
Plugin Author
Steve
(@stvwhtly)
Hi,
I’ve installed the WP SEO plugin mentioned and copied the snippet I wrote into the themes functions.php file (in this case TwentyTwelve), however it worked as expected for my tests.
One small modification I would suggest is to remove any markup / tags using the following:
add_filter( 'wpseo_metadesc', function( $description ) {
global $post;
if ( $subheading = get_post_meta( $post->ID, '_subheading', true ) ) {
return $subheading;
}
return $description;
} );
The issue you are having may be related to PHP versions, one thing I can suggest is removing the anonymous function used:
function wpseo_metadesc_subheading( $description ) {
global $post;
if ( $subheading = get_post_meta( $post->ID, '_subheading', true ) ) {
return $subheading;
}
return $description;
}
add_filter( 'wpseo_metadesc', 'wpseo_metadesc_subheading' );
As the theme functions file is included in the admin, any error introduced to the file will cause the 500 error you are seeing. With debugging and error outputting enabled it would probably show the actual error in more detail.
The second snippet worked like a charm. Thanks a lot!