{"id":266296,"date":"2026-01-07T15:20:33","date_gmt":"2026-01-07T15:20:33","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/random-posts-for-query-loop-block\/"},"modified":"2026-01-07T20:22:15","modified_gmt":"2026-01-07T20:22:15","slug":"random-posts-for-query-loop-block","status":"publish","type":"plugin","link":"https:\/\/pcd.wordpress.org\/plugins\/random-posts-for-query-loop-block\/","author":13882421,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.0.5","stable_tag":"1.0.5","tested":"6.9.4","requires":"6.0","requires_php":"7.4","requires_plugins":null,"header_name":"Random Posts for Query Loop Block","header_author":"Abhay Rautela","header_description":"Adds \"rand\" as a valid orderby value in the REST API so the Query Loop block can safely use random order (orderby=rand) without editor issues.","assets_banners_color":"328dc2","last_updated":"2026-01-07 20:22:15","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/ko-fi.com\/conetrees","header_plugin_uri":"https:\/\/conetrees.com\/products\/wordpress-plugins\/random-posts-query-loop\/","header_author_uri":"https:\/\/abhayrautela.com\/","rating":0,"author_block_rating":0,"active_installs":0,"downloads":157,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"1.0.5":{"tag":"1.0.5","author":"Ctrs","date":"2026-01-07 20:22:15"}},"upgrade_notice":{"1.0.5":"<p>Initial public release. Safely enables random ordering in the Query Loop block without breaking the Site Editor preview.<\/p>"},"ratings":[],"assets_icons":{"icon-256x256.png":{"filename":"icon-256x256.png","revision":3434605,"resolution":"256x256","location":"assets","locale":""}},"assets_banners":{"banner-1544x500.png":{"filename":"banner-1544x500.png","revision":3434605,"resolution":"1544x500","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.5"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":3434682,"resolution":"1","location":"assets","locale":""},"screenshot-2.png":{"filename":"screenshot-2.png","revision":3434682,"resolution":"2","location":"assets","locale":""}},"screenshots":{"1":"Query Loop block configured with <code>\"orderBy\": \"rand\"<\/code> in the Code Editor.","2":"Site Editor preview working correctly with random post ordering enabled.","3":"<p>Save the template.<\/p>","4":"<p>The Query Loop will now return one random post on each page load, and the Site Editor preview will continue to work normally.<\/p>"},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[148857,148076,4647,213445,244],"plugin_category":[],"plugin_contributors":[253514],"plugin_business_model":[],"class_list":["post-266296","plugin","type-plugin","status-publish","hentry","plugin_tags-block-editor","plugin_tags-gutenberg","plugin_tags-orderby","plugin_tags-query-loop","plugin_tags-random","plugin_contributors-ctrs","plugin_committers-ctrs"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/random-posts-for-query-loop-block\/assets\/icon-256x256.png?rev=3434605","icon_2x":"https:\/\/ps.w.org\/random-posts-for-query-loop-block\/assets\/icon-256x256.png?rev=3434605","generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/random-posts-for-query-loop-block\/assets\/screenshot-1.png?rev=3434682","caption":"Query Loop block configured with <code>\"orderBy\": \"rand\"<\/code> in the Code Editor."},{"src":"https:\/\/ps.w.org\/random-posts-for-query-loop-block\/assets\/screenshot-2.png?rev=3434682","caption":"Site Editor preview working correctly with random post ordering enabled."}],"raw_content":"<!--section=description-->\n<p>The Query Loop block in WordPress does not include a \"Random\" ordering option in the sidebar UI.<br \/>\nHowever, WordPress core <em>does<\/em> support <code>orderby = rand<\/code> in <code>WP_Query<\/code>.<\/p>\n\n<p>The problem:<br \/>\nUsing <code>\"orderBy\": \"rand\"<\/code> inside a Query Loop block can cause the <strong>Site Editor preview to fail<\/strong>, because <code>rand<\/code> is not included in the REST API schema for posts.<\/p>\n\n<p>This plugin fixes that by extending the REST API orderby enum so the editor recognizes <code>\"rand\"<\/code> as valid.<\/p>\n\n<h3>\u2714 What this plugin does<\/h3>\n\n<ul>\n<li>Adds <code>\"rand\"<\/code> to the REST API <code>orderby<\/code> enum for posts and pages.  <\/li>\n<li>Allows the Query Loop block to use <code>\"orderBy\": \"rand\"<\/code> safely.  <\/li>\n<li>Prevents JSON errors and broken previews in the Site Editor.  <\/li>\n<li>Makes \u201crandom post\u201d layouts work reliably both in the editor and frontend.<\/li>\n<\/ul>\n\n<h3>\u26a0 What this plugin does <em>not<\/em> do<\/h3>\n\n<ul>\n<li>It does <strong>not<\/strong> add a \u201cRandom\u201d option to the Query Loop UI dropdown.<br \/>\n(That UI is defined in Gutenberg\u2019s JavaScript.)<\/li>\n<li>You must still set <code>\"orderBy\": \"rand\"<\/code> manually using the Code Editor.<\/li>\n<\/ul>\n\n<h3>Example use case<\/h3>\n\n<p>Want your homepage, blog, quotes site, testimonials, or featured-section to show<br \/>\n<strong>a different post every time the page loads?<\/strong><\/p>\n\n<p>Install this plugin \u2192 open the template \u2192 switch to Code Editor \u2192 set <code>\"orderBy\": \"rand\"<\/code>.<\/p>\n\n<!--section=installation-->\n<ol>\n<li><p>Upload the plugin folder to <code>\/wp-content\/plugins\/random-posts-for-query-loop-block\/<\/code><br \/>\nor install it via <strong>Plugins \u2192 Add New \u2192 Upload Plugin<\/strong>.<\/p><\/li>\n<li><p>Activate the plugin via <strong>Plugins \u2192 Installed Plugins<\/strong>.<\/p><\/li>\n<li><p>Open the <strong>Site Editor<\/strong> and edit a template or page containing a <strong>Query Loop<\/strong> block.<\/p><\/li>\n<li><p>Switch to <strong>Code Editor<\/strong><br \/>\n(top-right kebab menu \u2192 <em>Code editor<\/em>).<\/p><\/li>\n<li><p>Find the <code>wp:query<\/code> block and set:<\/p>\n\n<p>\"orderBy\": \"rand\"<\/p><\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt id='will%20this%20add%20a%20%E2%80%9Crandom%E2%80%9D%20option%20to%20the%20query%20loop%20sidebar%3F'><h3>Will this add a \u201cRandom\u201d option to the Query Loop sidebar?<\/h3><\/dt>\n<dd><p>No. The dropdown list is defined in Gutenberg\u2019s JavaScript and cannot be modified by PHP alone.<br \/>\nYou must edit the block\u2019s attributes in <strong>Code Editor<\/strong>.<\/p><\/dd>\n<dt id='does%20this%20affect%20frontend%20queries%20outside%20the%20block%20editor%3F'><h3>Does this affect frontend queries outside the block editor?<\/h3><\/dt>\n<dd><p>No. It only extends the REST API schema used by the editor.<br \/>\n    WP_Query has natively supported <code>orderby = 'rand'<\/code> for many years.<\/p><\/dd>\n<dt id='does%20this%20slow%20down%20my%20website%3F'><h3>Does this slow down my website?<\/h3><\/dt>\n<dd><p>No extra load is added beyond core WordPress behavior.<br \/>\nHowever, <code>orderby = rand<\/code> can be heavy for very large datasets \u2014 this is true with or without this plugin.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.0.5<\/h4>\n\n<ul>\n<li>Initial release. Adds <code>rand<\/code> to the REST API <code>orderby<\/code> enum so Query Loop can safely use random order.<\/li>\n<\/ul>","raw_excerpt":"Adds &quot;rand&quot; to the REST API orderby options so the Query Loop block can use random post order safely without breaking the Site Editor preview.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/266296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=266296"}],"author":[{"embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/ctrs"}],"wp:attachment":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=266296"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=266296"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=266296"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=266296"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=266296"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=266296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}