Display recently viewed products

You can use Post loop builder to show recently viewed products. Follow these steps:

  1. Add Post loop builder

  2. Select Query > Array

  3. Enter this array:

return [
'post_type' => 'product',
'posts_per_page' => 4,
'meta_key' => '_last_viewed',
  'orderby' => 'meta_value',
'order' => 'DESC',
];

Important part is meta_key "last_viewed".

Last updated