Skip to content

Instantly share code, notes, and snippets.

@jeherve
Created December 16, 2013 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeherve/7990726 to your computer and use it in GitHub Desktop.
Save jeherve/7990726 to your computer and use it in GitHub Desktop.
[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