How to fix forever similar posts in wordpress?

Hi, did a plug, it is necessary that similar posts are fixed there for forever, that is, they have not been updated nor when even if you delete the cache.
How to do that, who knows? here is my code

$categories = get_the_category(get_the_ID()); 
if ($categories) {
 $category_ids = array();
 foreach($categories as $individual_category) {

 $category_ids[] = $individual_category->term_id;

 'category__in' => $category_ids,
 'post__not_in' => array(get_the_ID()),
 'showposts' => '5',
 'orderby' => 'rand',
 'ignore_sticky_posts' => '1',
 'no_found_rows' => true,
 'cache_results' => true
 $my_query = new wp_query($args);
 if( $my_query->have_posts() ) {
 echo '<ul>';
 while ($my_query->have_posts()) {
 the <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
 echo '</ul>';
March 23rd 20 at 19:44
1 answer
March 23rd 20 at 19:46
In array to add the post__in(array)

Specify an array of IDs of posts that need to get post__in => [5,12,2,14,7].

Note: if you have taped record they will be included with the machine. Disable them by setting ignore_sticky_posts.
I have a few thousand posts, that's not an option, the only option I see here is the need to cache the query $my_query = new wp_query($args); after the initial download, either in files or in database to make this cache is never removed - beau_Rempel commented on March 23rd 20 at 19:49
So you in similar positions to display a few thousand posts? - Althea44 commented on March 23rd 20 at 19:52
@Althea44, not 10 pieces, but the volume of posts a few thousand and I have no idea how every post ask post__in => [5,12,2,14,7].(that would've been a different similar posts each post) - beau_Rempel commented on March 23rd 20 at 19:55
And what if not satisfied with the version by tag or by category? Or to add your taxonomy and posts add to the group. Or add a condition by date. It all depends on what positions you need to fix. On what grounds. - Althea44 commented on March 23rd 20 at 19:58

Find more questions by tags WordPress