// if no title function simplehomepage_custom_document_title() { if (!get_the_title()&&get_the_content()){ return esc_html(wp_trim_words(get_the_content(), 20, '...')) . " – " . get_bloginfo('name'); } } add_filter( 'pre_get_document_title', 'simplehomepage_custom_document_title');
For my WordPress theme, I wrote a function in the function.php file that creates a page title from the content if the post didn't have one. Is this function safe as is, or do I need to change something? #WP #WordPress #coding #programming #PHP