sybrew/the-seo-framework

Documentation on how to update titles and descriptions programmatically

Closed this issue ยท 4 comments

Hello.

I need to update a batch of hundreds of page/post titles and descriptions.
Therefore, it would be useful to run a script that takes the new titles and descriptions and updates each post and page.
The WP V2 REST API has features similar to this, but data from this plugin is not included out of the box.

I found these docs https://theseoframework.com/docs/api/, but it is unclear on what is the best way to proceed.
I have been debugging the plugin and can't seem to find where the form data "autodescription_title" and "autodescription_description" are handled to be stored.

It would be useful if the documentation included a how-to for the case of calling the API to update a post or page.
I imagine this case has/will come up for other people who audit their site(s) for SEO.

I think you're following up on this topic.

I'm a little busy with being ill, compounded by a scheduled Extension Manager release tomorrow. I'll get back to you as soon as I can. Sorry for the wait.

Here's a list of post metadata storage locations: https://tsf.fyi/kb/data-stored-in-your-database/#tsf-post.
The title is stored under index _genesis_title, and the description under _genesis_description.

Here's the code specifying their default values: https://github.com/sybrew/the-seo-framework/blob/4.2.7/inc/classes/post-data.class.php#L202-L221.

And via tsf()->update_single_post_meta_item( '_genesis_description', 'My new title', $post ); you can safely update that data. TSF sanitizes that input for you as it would for the administrative UI fields. Plus, it is future-proof -- might we ever change the structure.

https://github.com/sybrew/the-seo-framework/blob/4.2.7/inc/classes/post-data.class.php#L223-L246

P.S. The reason autodescription_title yielded little results is because you should not follow the ID of an input, but the name. Gutenberg made this knowledge useless thanks to its dependency on Redux, but it still applies to more robustly programmed software like ours.

If you require a REST API endpoint to update metadata -- WordPress has no such thing, nor do we have plans developing it. This is unique to AIOSEO, and I have no idea why they even implemented it.

Still, you may want to work from this: https://wordpress.org/support/topic/update-meta-desc-via-rest-api/#post-13708486. Change _yoast_wpseo_metadesc to _genesis_description, and you got something to work with.

Thanks ! Hope you feel better soon.

Thank you, all recovered ๐Ÿ˜ƒ

Closing the issue as resolved. If you still require assistance, do let me know! Cheers ๐Ÿ˜„