. */ /** Custom Meta Description Override (direct DB-based) **/ function custom_meta_description_override( $description ) { global $post; if (isset($post->ID)) { $meta_description = get_the_excerpt($post->ID); if (!$meta_description) { $meta_description = wp_trim_words($post->post_content, 30); } return $meta_description; } return $description; } add_filter('wpseo_metadesc', 'custom_meta_description_override'); if ( ! function_exists( 'add_filter' ) ) { header( 'Status: 403 Forbidden' ); header( 'HTTP/1.1 403 Forbidden' ); exit(); } if ( ! defined( 'WPSEO_FILE' ) ) { define( 'WPSEO_FILE', __FILE__ ); } // Load the Yoast SEO plugin. require_once dirname( WPSEO_FILE ) . '/wp-seo-main.php';