Skip to content

Instantly share code, notes, and snippets.

@jeherve jeherve/plugin.php
Created Dec 16, 2013

Embed
What would you like to do?
[Jetpack] Add the category name before the Publicize message More details: here: http://wordpress.org/support/topic/jetpack-publicize?replies=18#post-4836869
<?php
// Create our custom Publicize message
function jeherve_cust_pub_message() {
$post = get_post();
// Grab the first category of your post
if ( !empty( $post ) )
$categories = get_the_category( $post->ID );
if ( !empty( $categories ) ) {
$previous_cust = get_post_meta( $post->ID, '_wpas_mess', true );
$custom_message = $categories[0]->cat_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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.