One easy way that comes to mind is to hide the elements in the mobile view via CSS using the nth-child
selector.
That way, all five elements are still rendered in the source code, but only two of them are visible on devices below a certain resolution.
Example code assuming your product items are elements of the class item
inside a container with the class products
:
@media (max-width: 480px) /* replace with whatever mobile threshold the rest of your
CSS is using */
{
.products .item { display: none } /* Hide all elements by default */
.products .item:nth-child(1), /* Selectively re-enable 1st and 2nd element */
.products .item:nth-child(2)
{
display: block; /* Or whatever the elements' original display value is */
}
}
You can extend this code (using combinations of min-width
and max-width
) to adjust the number of items for very narrow and very large screens, too.
Related Posts:
- How can I define a custom template for woocommerce [products] shortcode? [closed]
- Shortcode with product catgory counter
- wc_get_product in a none woocommerce page
- WooCommerce Multi-Currency shortcode not working
- shortcode to display woocommerce cart total
- Products Shortcode is Displaying Single Product Page Price for all Products [closed]
- How can I custom order the product display?
- Woocommerce Shortcode custom orderby not working
- Override static method in WC_Shortcodes class (shortcode) [closed]
- Unable to pull in custom product attribute in shortcode [closed]
- Adding author option to [products] woocommerce shortcode
- Pass class to Woocommerce shortcode [relative_products] [closed]
- Create a shortcode for native WooCommerce search form [closed]
- How can i access woocommerce order variables inside shortcode?
- porto theme pagination on woocommerce not working
- Jump to Footer On Scroll – Woocommerce Pages Phones Only
- How to display 2 products per row for Mobile using WooCommerce?
- I want to show always 4 category boxes everytime in woocommerce
- How to use products shortcode in taxonomy-product_cat with multiple columns?
- Why isn’t working WooCommerce session inside shortcode?
- Shortcodes in billing fields doesn’t work
- How to check which shortcode is using my template?
- deactivate product-page image slider on mobile
- How to add a fixed shopping cart button on the bottom of the page?
- If YITH Wishlist page is set to the WooCommerce my-account endpoint, the endpoints stop working all together. Any solution?
- Creating a shortcode with a variable (Woocommerce)?
- Trying to insert a div ID link into Woocommerce shortcode Pagination
- how should i get products based on tags in woocommerce
- WooCommerce: Can’t use wc_get_products for custom REST API endpoints
- How to remove an action within a class with extends
- Display WooCommerce size product attribute on shop page
- woocommerce_before_calculate_totals in woocommerce 3.0
- Display a list subcategories under the main product category thumbnails?
- Unable to programmatically remove product from WooCommerce cart
- creating product with variations using woocommerce REST API
- How to Change WooCommerce Variable product pricing by SKU or visible children id
- Is it possible to cache ?wc-ajax=get_variation
- Adding extra one email address who receives email as admin – woocommerce
- How to set default values in Woocommerce checkout? [closed]
- Display list of categories that contain products with a specific tag
- Payment methods are not displaying in Woocommerce
- How to display empty stars on products with woocommerce?
- Product admin page breaking with too many product variations [closed]
- Product options/variations notice displays as an Alert [closed]
- Expired session error (admin) when I try to make a call to WooCommerce api [closed]
- Hide decimal on hompage, category and product page
- Get order_id from the product_id in woocommece [closed]
- Shipping methods in dropdown instead of radio buttons [closed]
- 600k of option_name “c_facebook_background_product_sync_job”
- Woocommerce get the Archive/Category slug of the current category page
- Woocommerce Variable Product – Please choose product options… [closed]
- woocommerce_order_status_completed not working
- Woocommerce. Max weight per order based on shipping class
- Make order notes field at woocommerce checkout only viewable on front end by Admin level user role [closed]
- Woocommerce checkout field
- Woocommerce – auto logout after payment
- Display SKU for each Single product title in group product!
- How can I add a so i can show sale price under normal price
- how to change add to cart button to call for price button in one of product variation?
- Next/Previous Product with custom order by price & products inside the product category [closed]
- Submitting product attributes via Ninja Forms wordpress?
- Migrating WordPress + WooCommerce from server to Local
- wp-cron and woocommerce subscriptions killing performance
- How to Add “parent category description” in Woocommerce sub category page if there is no description available for child category
- Woocommerce – Hide shipping at all, if only certain product or products with certain shipping class is in the cart
- Woocommerce product query not working in other WPML languages
- Woocommerce get attributes
- Add custom field address_3 before city in user profile
- Get $order in wp_head
- Update WooCommerce stock status with SQL query if stock value is greater than 0
- How to find which last line executed in wordpress?
- Adding order details in woocommerce all booking dashboard
- woocommerce cart related issue cart not deleted
- WooCommerce – Hide price and add to cart button
- Send a different “thank you” email based on payment method
- Delete product image using WooCommerce API?
- Empty Cart on just mobile and Microsoft edge browser
- How to add a special Woocommerce “Buy Now” button?
- WP All import sale price 0 [closed]
- WooCommerce database upgrade behaviour
- Integration widget Mondial Relay Js
- Replace product link with just product name on WooCommerce downloads page
- Importing Attributes in to Woocommerce
- woocomerce products and categories don’t display fixed
- Update Custom Post Meta Even if Draft
- Woocommerce Shipping based on condition and cart value
- Clone and modify Woocommerce Products catalog
- Update order status based on condition
- How to add ajax loading icon after click add to cart button on woocommerce
- WooCommerce Table Rates not splitting up
- How can I let the user choose size of a shoe in the store? [closed]
- Hide/show specific products for backend users in woocommerce
- I’d like to add a button under the “Add to Cart” button which says “Buy on Amazon” and links to my Amazon product page [closed]
- WooCommerce pay per photo upload [closed]
- Override woocommerce template from parent theme
- Woocommerce checkout column total too small can not get it wider [closed]
- WooCommerce – How to add a custom field to only a specific email template [closed]
- error 500 in Back Office when using a woocommerce function in functions.php
- How to update all products with same SKU prefixes when updating stock with CSV?
- What is the best and cheapest way to generate dashboards about conversions data and store users? [closed]