Skip to content

firstandthird/wordpress-unique-query

Repository files navigation

unique-wp-query

unique-wp-query is a Wordpress plugin that can be used to ensure no post is loaded more than once per screen

Features

  • ensures only one of each post is loaded

Installation

just put the root folder in your wp-content/plugins directory and Activate from the plugins console

Usage:

From the demo:

$latest_posts1 = new Unique_WP_Query([
  'post_type' => 'post',
  'posts_per_page' => 3,
  'post_status' => 'publish',
  'post__not_in' => array(18)
]);
$latest_posts2 = new Unique_WP_Query([
  'post_type' => 'post',
  'posts_per_page' => 3,
  'post_status' => 'publish',
]);
while ($latest_posts1->have_posts()) {
  $latest_posts1->the_post();
  echo get_the_title(), '<br>';
}
echo "<br><br>---------------------------------------------------------------------<br><br>";
while ($latest_posts2->have_posts()) {
  $latest_posts2->the_post();
  echo get_the_title(), '<br>';
}

The second list will not include any posts that were in the first

Demo:

This repo includes a docker-compose with a dummy theme that demonstrates the plugin, to use it:
    - __docker-compose up__
    - Open a browser and log in to the Wordpress server
    - Add some dummy posts and then load the main page

A First + Third Project

About

A plugin for doing unique WP_Query

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •