The best way to store variable across different widgets
The front page of my site building with set of widgets. Each widget shows the rows with posts for some criteria.
I want to exclude duplicate posts across different widgets. The simplest way comes to mind is to use global variable.
For example:
global $exclude;
$query = new WP_Query([
'posts_per_page' = publish,
'post__not_in' = $exclude
]);
$exclude = wp_list_pluck( $query-posts, 'ID' );
I want to find better way to do this job. I've thought about wp_get_cache
, but it seems that it is not what I want.
Topic post-duplication wp-query Wordpress
Category Web