Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wp-seopress/0ebb575dcf5ad22d5be5af490ba6f033 to your computer and use it in GitHub Desktop.
Save wp-seopress/0ebb575dcf5ad22d5be5af490ba6f033 to your computer and use it in GitHub Desktop.
Filter the request to generate a meta title with AI
add_filter('seopress_ai_openai_meta_title', 'sp_ai_openai_meta_title', 10, 2);
function sp_ai_openai_meta_title($prompt, $post_id) {
//$content = get_post_field('post_content', $post_id);
//$content = esc_attr(stripslashes_deep(wp_filter_nohtml_kses(wp_strip_all_tags(strip_shortcodes($content)))));
//$content = wp_trim_words( $content, 500 );
$language = 'fr_FR'; //example with French locale, replace with your own language code
$prompt = 'Generate, in this language ' . $language . ', an engaging SEO title metadata in one sentence of sixty characters maximum for this article: ' . $content;
return $prompt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment