{"id":1769,"date":"2024-09-26T13:44:50","date_gmt":"2024-09-26T13:44:50","guid":{"rendered":"http:\/\/docs"},"modified":"2024-09-26T13:44:50","modified_gmt":"2024-09-26T13:44:50","password":"","slug":"random-order-for-the-shop-page-sorting","status":"publish","type":"docs","link":"https:\/\/www.8theme.com\/documentation\/xstore\/additional-customisation\/random-order-for-the-shop-page-sorting\/","title":{"rendered":"Random order for the shop page sorting"},"content":{"rendered":"<p>To add the Random sorting type for your shop page add the code below to child theme <code class=\"inline-code\">functions.php<\/code>file:<\/p>\n<pre>add_filter( &#39;woocommerce_get_catalog_ordering_args&#39;, &#39;custom_woocommerce_get_catalog_ordering_args&#39; );\n \nfunction custom_woocommerce_get_catalog_ordering_args( $args ) {\n$orderby_value = isset( $_GET[&#39;orderby&#39;] ) ? woocommerce_clean( $_GET[&#39;orderby&#39;] ) : apply_filters( &#39;woocommerce_default_catalog_orderby&#39;, get_option( &#39;woocommerce_default_catalog_orderby&#39; ) );\n \nif ( &#39;random_list&#39; == $orderby_value ) {\n$args[&#39;orderby&#39;] = &#39;rand&#39;;\n$args[&#39;order&#39;] = &#39;&#39;;\n$args[&#39;meta_key&#39;] = &#39;&#39;;\n}\nreturn $args;\n}\n \nadd_filter( &#39;woocommerce_default_catalog_orderby_options&#39;, &#39;custom_woocommerce_catalog_orderby&#39; );\nadd_filter( &#39;woocommerce_catalog_orderby&#39;, &#39;custom_woocommerce_catalog_orderby&#39; );\n \nfunction custom_woocommerce_catalog_orderby( $sortby ) {\n$sortby[&#39;random_list&#39;] = &#39;Random&#39;;\nreturn $sortby;\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To add the Random sorting type for your shop page add the code below to child theme functions.phpfile: add_filter( &#39;woocommerce_get_catalog_ordering_args&#39;, &#39;custom_woocommerce_get_catalog_ordering_args&#39; ); function custom_woocommerce_get_catalog_ordering_args( $args ) { $orderby_value = isset( $_GET[&#39;orderby&#39;] ) ? woocommerce_clean( $_GET[&#39;orderby&#39;] ) : apply_filters( &#39;woocommerce_default_catalog_orderby&#39;, get_option( &#39;woocommerce_default_catalog_orderby&#39; ) ); if ( &#39;random_list&#39; == $orderby_value ) { $args[&#39;orderby&#39;] = &#39;rand&#39;; $args[&#39;order&#39;] = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"doc_category":[42],"doc_tag":[],"class_list":["post-1769","docs","type-docs","status-publish","hentry","doc_category-additional-customisation"],"aioseo_notices":[],"year_month":"2026-04","word_count":108,"total_views":"2443","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"author_nicename":"docs","author_url":"https:\/\/www.8theme.com\/documentation\/author\/docs\/"},"doc_category_info":[{"term_name":"Additional Customization","term_url":"https:\/\/www.8theme.com\/documentation\/xstore\/additional-customisation\/"}],"doc_tag_info":[],"author_list":[{"ID":"1","user_login":"docs","display_name":"docs","id":"1"}],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/docs\/1769","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/comments?post=1769"}],"version-history":[{"count":0,"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/docs\/1769\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/media?parent=1769"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/doc_category?post=1769"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/doc_tag?post=1769"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}