Skip to content

Instantly share code, notes, and snippets.

@wp-seopress
Last active March 10, 2026 14:49
Show Gist options
  • Select an option

  • Save wp-seopress/76417746ed5cdb8a34270e65b611368d to your computer and use it in GitHub Desktop.

Select an option

Save wp-seopress/76417746ed5cdb8a34270e65b611368d to your computer and use it in GitHub Desktop.
Filter AI generated social metadata
<?php
// Filter the X description generated by OpenAI
add_filter( 'seopress_ai_openai_social_twitter_description', 'sp_ai_openai_social_twitter_description', 10, 2 );
function sp_ai_openai_social_twitter_description( $prompt, $post_id ) {
// Example: prepend post type label
$post_type_obj = get_post_type_object( get_post_type( $post_id ) );
if ( $post_type_obj && ! empty( $post_type_obj->labels->singular_name ) ) {
$prompt = $post_type_obj->labels->singular_name . ': ' . $prompt;
}
// Example: append brand + handle
$prompt .= ' — ' . _e( 'Powered by MyBrand (@mybrand)', 'your-text-domain');
return $prompt;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment