Skip to content

Commit 001f084

Browse files
committed
Word count function now ignores shortcodes
1 parent 388c032 commit 001f084

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

includes/functions/_wordpress_mods.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,15 @@ function fictioneer_save_word_count( $post_id ) {
209209
return;
210210
}
211211

212-
$word_count = str_word_count( strip_tags( get_post_field( 'post_content', $post_id ) ) );
212+
// Prepare
213+
$content = get_post_field( 'post_content', $post_id );
214+
$content = strip_shortcodes( $content );
215+
$content = strip_tags( $content );
216+
217+
// Count
218+
$word_count = str_word_count( $content );
219+
220+
// Remember
213221
update_post_meta( $post_id, '_word_count', $word_count );
214222
}
215223
}

0 commit comments

Comments
 (0)