You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a term is updated (and, that update impacts term data stored with posts, which OOTB includes the slug, name, and parent), an async task should kick off which loops through all posts in the term and reindexes them. Note that a term could have any number of posts (thousands, even millions!), so care must be taken to do this as efficiently as possible.
Implementation Notes
After #98, that async task could simply update the post meta to flag that the post needs reindexing, and a separate indexing task will handle that process. However, that ultimately requires querying for each post twice: the first time via term, and the second via post meta. It might make more sense to reindex the post in the same async process that queries for the posts in the updated term, although that would likely be less DRY.
The text was updated successfully, but these errors were encountered:
This could all be done pretty efficiently in MySQL, and we'd just need to clear the relevant object cache keys. In short, query for all post ids in the term, and insert into the post meta table the key, value _sp_index,1. The query could be as simple as...
$wpdb->query(
$wpdb->prepare(
"INSERT INTO {$wpdb->postmeta} (`post_id`, `meta_key`, `meta_value`) SELECT `object_id`, '_sp_index', '1' FROM {$wpdb->term_relationships} WHERE `term_taxonomy_id` = %d",
$term_id
)
);
Not sure offhand what object cache keys would need to be cleared after that.
Likely requires: #98
When a term is updated (and, that update impacts term data stored with posts, which OOTB includes the
slug
,name
, andparent
), an async task should kick off which loops through all posts in the term and reindexes them. Note that a term could have any number of posts (thousands, even millions!), so care must be taken to do this as efficiently as possible.Implementation Notes
After #98, that async task could simply update the post meta to flag that the post needs reindexing, and a separate indexing task will handle that process. However, that ultimately requires querying for each post twice: the first time via term, and the second via post meta. It might make more sense to reindex the post in the same async process that queries for the posts in the updated term, although that would likely be less DRY.
The text was updated successfully, but these errors were encountered: