Answer the question
In order to leave comments, you need to log in
How to trim url when saving posts?
I need it to be saved with a shortened url when saving a post, a maximum of 3 words, I added code (2 hooks) to functions.php, but they do not work, tell me what I'm doing wrong
function action_function_name( $post_ID) {
$post_url = get_permalink ( $post_ID );
return wp_trim_words( $post_url, 3, $more=null );
}
add_action( 'save_post', 'action_function_name', 10, 3 );
function trimwords()
{
global $post;
$post_url = get_permalink( $post);
return wp_trim_words( $post_url, 3, $more=null );
}
add_action('save_post_news', 'trimwords', 10);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question