Title: Coding a default custom message on Publicize
Last modified: August 31, 2016

---

# Coding a default custom message on Publicize

 *  [jmhusher](https://wordpress.org/support/users/jmhusher/)
 * (@jmhusher)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/coding-a-default-custom-message-on-publicize/)
 * Hi there,
 * Thanks to the great Jeremy Herve on ([https://wordpress.org/support/topic/jetpack-publicize?replies=18](https://wordpress.org/support/topic/jetpack-publicize?replies=18)),
   using a Functionality plugin I’ve been able to define a default custom message
   for all new posts. However, the code supplied defined the category of the post.
 * I was wondering, would anyone know how to manipulate his suggested code (below)
   to grab just the title of the post? That would then be used for the custom message.
 *     ```
       // 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' );'
       ```
   
 * If possible, the custom message could be ‘title’ by ‘author’. But my main headache
   is getting the title into that code! I’ve tried implementing `get_title`, but
   to no avail. I know Publicize has filters defined for use with the custom message,
   but I’m not sure how to implement them. I have a working knowledge of PHP, but
   not fluent.
 * Any help would be hugely appreciated!

The topic ‘Coding a default custom message on Publicize’ is closed to new replies.

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [custom message](https://wordpress.org/support/topic-tag/custom-message/)
 * [message](https://wordpress.org/support/topic-tag/message/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [publicize](https://wordpress.org/support/topic-tag/publicize/)
 * [sharing](https://wordpress.org/support/topic-tag/sharing/)
 * [social](https://wordpress.org/support/topic-tag/social/)
 * [twitter](https://wordpress.org/support/topic-tag/twitter/)

 * 0 replies
 * 1 participant
 * Last reply from: [jmhusher](https://wordpress.org/support/users/jmhusher/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/coding-a-default-custom-message-on-publicize/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
