Hi @sweetheatmn,
Thanks for reaching out!
I understand you’re trying to programmatically set the meta description for posts. However, I’d like to clarify that All in One SEO stores its data in custom tables (e.g., the wp_aioseo_posts
table for post-related data), not in the postmeta table.
The _aioseo_description
and other related fields you’re seeing in the postmeta table are actually duplicates created for compatibility purposes with plugins like WPML. These fields are not directly used by AIOSEO to retrieve or display SEO data.
If you only need to set the meta description, you can use the aioseo_description
filter to dynamically set it.
Here’s an example code snippet you can use:
add_filter( 'aioseo_description', 'aioseo_set_custom_meta_description' );
function aioseo_set_custom_meta_description( $description ) {
// Check if you're on the desired post.
if ( is_singular() && get_the_ID() === 123 ) { // Replace 123 with the ID of your post.
return "Your custom meta description here.";
}
return $description;
}
Let me know if you have further questions or if there’s anything else I can assist you with. I’m happy to help!