While researching for this I came across Categories and products in random order which had a similar but different issue but was able to derive the required information to cut the array.
I modified his $categories = array_slice( $categories, 0, 5 );
to suit my needs. Final answer was just to add an array_slice based on $cat_number
so I modified $all_categories and called it just $categories (as I will later reference $all_categories) and changed the code to following
$categories = get_categories( $args );
$_totals = count($categories);
shuffle($categories);
$all_categories = array_slice( $categories, 0, $number_cats );
Related Posts:
- retrieve thumbnail from post ID of best selling product in category
- Woocommerce – remove product from category
- combine Code 1 with Code 2
- get current product name in functions.php
- Issue adding sub category programmatically
- Pass Category Name, Description and Photo into variables to pass to jQuery
- get taxonomy thumbnail and use it as a variable in code
- Only show size attributes in product box woocommerce when available
- WooCommerce: Display product categories to make IF statement
- Display Sibling WooCommerce Product Categories on Archive Page
- Woocommerce. Get a list of products in the current category on the archive page and product page
- Add Custom Category Description When Empty
- Add a product category to a specific product via a button
- Child-Theme Category View with modified permalinks (%category% removed)
- Need Quick Help With Product Category Page
- WordPress using get_term to retreive slug not working as expected
- How to remove image on single product and get product to span page?
- Product Category Page in Full Width
- Hide child of parent categories already hidden with “get_terms_args” – Woocommerce
- Swapping wp_dropdown_categories function with wp_category_checklist
- Automatically remove a canceled order in Woocommerce
- Parent theme CSS overriding child CSS rules
- Call global variable array() in woocommerce child/template
- How to style options page in dashboard?
- Remove price from Woocommerce variable product dropdown menu
- Proper syntax or method for keeping url in modified isotope / category links
- Adding nofollow to a PHP generated Nav
- Filter Select results based on selection
- What is an equivalent of single_cat_title for getting the slug of the category?
- Automated Cart Update With Alert Box Each Time
- Two Different Links for Same Product – WooCommerce [closed]
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- dividing sub-categories by parent category – WordPress
- Show prices with tax in Woocommerce Mini Cart [closed]
- How to exclude category ID from Looper in WordPress
- Add a specific part of current category page url to shortcode
- Woocommerce product variation backorder
- Status 400 for AJAX POST Request with admin-ajax.php
- how do I get a specific post from a post with a subcategory in WP
- Problem with custom plugin using AJAX to pull info from php file
- Woocommerce hook run after an Order been created through REST API
- How can I apply_filters from inside a function?
- Get and insert order email address to the PHP template inside HTML text
- WP grandchild categories in nested ul li
- Modify HTML structure of fields in woocommerce checkout form
- Grab posts by multiple categories
- Auto-update products after they were published – Woocommerce
- How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
- Reload part of checkout on changed shipping method
- How to show single category archive
- How to get all shipping rates and costs without session in woocommerce?
- Move category description below post list in blog
- Display a specific category of products in shop page and disable code for specific actions
- If no products are on sale – hide ID or class
- Woocommerce related product text
- Woocommerce api: create product with images – bad request
- Trying to build simple deposit code that hooks into woocommerce
- WooCommerce Webhooks not firing because of error in wp-includes/meta.php
- Different Minimum Order Amounts based on Shipping Zone [closed]
- How to pick the default selected value in wordpress dropdown?
- do search in two site and show the result in first site
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- Add a product to checkout via form
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Trying to place a custom field after the total section in the checkout page in woocommerce
- Get page that displays all children of taxonomy parent
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Which field should I edit to make the checkbox marked by default?
- Displaying Woocommerce Product Category in WordPress
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- WooCommerce: How can I get orders with a custom ID in order meta data object?
- wordpress + woocommerce display product with additional information [closed]
- how to fix error “called incorrectly, should not be accessed directly”?
- Function works when I don’t login to WordPress but when I login then it doesn’t work
- How to auto fetch customer details in Woocommerce in checkout page
- Displaying custom taxonomy on WooCommerce product page
- Sum the total amount of a specific product purchased per user and display in table
- Change “add to cart” button color based on Woocommerce product category [closed]
- selected option if current category is the value
- How can I get the values of my WordPress $wpdb query in Jquery?
- How can I pass a custom/dynamic product to the Woocommerce cart?
- Add to cart function not working for first product when cart is empty [closed]
- I want to add custom add to cart link [closed]
- How to make products with no cost in WooCommerce
- Woocommerce : Can’t get product info in loop
- WooCommerce custom product dimensions
- get_template_part based upon post’s category
- Replace part of a parent-theme customizer in the child-theme
- how to save selected option in variable for rest api category filter
- Trouble checking if custom woocommerce checkout field is empty or not
- Incorrect amount of posts returned when filtering related Woo products by custom taxonomy
- Setting default category base on theme activation
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Validation algorithm in checkout field
- Hide subcategories (widget)
- Alert Bar section within WP loop is displaying even though there are no posts
- Let Users Choose Post Categories
- Different post styles depending on category
- How do I remove the product thumbnail link from a specific div in Woocommerce? [closed]
- Display category name only once inside loop