Created
December 16, 2013 17:21
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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