Get first sentence of instagram caption as post title?
-
Hi!
I’s like to know if there’s a way to combinepreg_match
andwp_insert_post_data
to fetch the first sentence of an instagram post when it’s importing to your WordPress? Basically to have it match the first dot, exclamation mark(!) or question mark(?)Right now I have to choose to either set a default post title which get’s boring over time (and confusing, maybe?), or have the whole caption as the post title and no description in the post content or repeat all of the text again.
I’m all ears for suggestions, and I’m an complete noob, so the simpler solution the better. Right now I’m using this, and it doesn’t work…
function filter_post( $data , $postarr ) { if (!preg_match('/(\.|!|\?)\s/', $data['post_title'])); return ( $data ); } add_filter ( 'wp_insert_post_data' , 'filter_post' , '99', 2 );
Any suggestions on how to solve this? BTW, found this code here and modified it a bit.
Thanks!
- The topic ‘Get first sentence of instagram caption as post title?’ is closed to new replies.