WP Manifestindependent plugin directory
manifest / developer / wpgraphql-random-orderby

WPGraphQL Random Orderby

Adds RAND (random) as an orderby option for WPGraphQL post queries.

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/dazza-dev/wpgraphql-random-orderby/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Adds RAND (random) as an orderby option for WPGraphQL post queries.

Description

By default, WPGraphQL does not support random ordering for posts. This lightweight plugin adds RAND to the PostObjectsConnectionOrderbyEnum, allowing you to retrieve posts in random order via GraphQL queries.

Requires WPGraphQL plugin to be installed and active.

Usage

Once activated, you can use RAND in your GraphQL queries:

query GetRandomPosts { posts(where: { orderby: { field: RAND } }) { nodes { id title slug } } }

Installation

  1. Upload the wpgraphql-random-orderby folder to /wp-content/plugins/.
  2. Activate the plugin through the "Plugins" menu in WordPress.
  3. Make sure WPGraphQL is installed and active.
  4. Use RAND as an orderby field in your GraphQL queries.

Frequently Asked Questions

Does this plugin require WPGraphQL?

Yes. This plugin extends WPGraphQL by adding a new orderby enum value. It will have no effect without WPGraphQL active.

Does it work with custom post types?

This plugin only adds random ordering for the default posts connection. To support custom post types, you would need to add the corresponding filter for each CPT (e.g., graphql_{YourCPT}ConnectionOrderbyEnum_values).

Changelog

1.0

  • Initial release.
  • Adds RAND orderby option to WPGraphQL post queries.