Sorry if this isn’t the right place to ask, but I can’t find the help I need anywhere…
How can I display featured products on my homepage? The closest I got was with shortcodes… but the styling was all messed up (potentially bootstrap 4 / woo conflicts). My product pages and everything else look and work properly, so I can’t understand what’s going on.
Any form of help or guidance will be greatly appreciated.
P.S. I’m using this sage-woo boilerplate for Sage 9 / WooCommerce.
I haven’t used WooCommerce in a while, but IIRC products are just a post type, and “featured” is probably some sort of taxonomy, so is there any particular reason you can’t just grab them with a get_posts()?
@shaneparsons yep, I would just take a quick look at the docs and see if that gets you pointed in the right direction. If you still have questions after that go ahead and follow up here. Data filters will be the simplest place to start.
I’m having trouble understanding how to implement either of those concepts though, so I’ll likely just move along for the time being so I can finish the website on time.
In the meantime, if anybody has time and wishes to help me understand filters and controllers more, It’d definitely be good to know in the near future. This link helped me a bit, but I still don’t fully understand how I’d convert my code above into it.
Example #1: Call to a member function have_posts() on null in ...
Example #2: Notice: Undefined variable: products in ... Warning: Invalid argument supplied for foreach() in ...
It feels like filters.php and front-page.blade.php aren’t communicating with each other properly and products ends up being null/undefined… Any ideas why?
Edit: I tried deleting Controller as per this discussion, but that didn’t seem to fix it.
It appears I spoke too soon… While deleting soberwp/controller fixed my filter issues, it appears to have broken my posts page (i.e. Class 'App' not found)… Is there a way to get filters and controllers to work in harmony? How should I go about fixing this?
I was able to convert the filter into a controller to overcome the issue in the meantime… but the conflict with filters is still a cause for concern. What does this mean for the default filters in filters.php? Are they working as intended?
I’d recommend against defining dev-master in your composer.json, since it means that every time you run composer update it’ll pull whatever’s at the tip of the master branch—which may break your site. Instead, if the head of master is working for you I recommend locking it to that commit, i.e.: