Hi there
You should be able to adapt the code here, using get_the_author_meta
instead of get_the_category
https://gist.github.com/jeherve/7990726
Hope that helps!
Thread Starter
CoFOX
(@coyotech)
I must be doing something wrong. It doesn’t seem to be working. Can you have a look at this any help is appreciated
// Create our custom Publicize message
function jeherve_cust_pub_message() {
$post = get_post();
// Grab the first category of your post
if ( !empty( $post ) )
$authors = get_the_author_meta( $post->ID );
if ( !empty( $authors ) ) {
$previous_cust = get_post_meta( $post->ID, '_wpas_mess', true );
$custom_message = $authors[0]->display_name . ' ' . $previous_cust;
update_post_meta( $post->ID, '_wpas_mess', $custom_message );
}
}
// Save that message
function jeherve_cust_pub_message_save() {
add_action( 'save_post', 'jeherve_cust_pub_message', 21 );
}
add_action( 'publish_post', 'jeherve_cust_pub_message_save' );
The easiest method would be manually entering in the desired info as mentioned here: https://jetpack.com/support/publicize/#how-to-add-custom-excerpts
If you are looking for something automated, there is the publicize_save_meta
action hook which could be of use: https://developer.jetpack.com/hooks/publicize_save_meta/
Here is a rough & incomplete example of what that might look like: https://gist.github.com/samiff/f8c6e39734afb50bfd6e089fab044cde
Such code would be added to a child theme’s functions.php file, in a custom mu-plugin, or by using a plugin such as Code Snippets.