Coding a default custom message on Publicize
-
Hi there,
Thanks to the great Jeremy Herve on (https://ww.wp.xz.cn/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.