Closed renatonascalves closed 3 years ago
@kjbenk I saw the homepages_modify_main_query
hook but I thought we should have an out of box solution, without having to resort to code.
The scenario I encountered would make this hook more troublesome than necessary. Push code to disable the query, create a homepage, publish it, and then push code again to reactivate it?
That seems like the wrong way to handle this problem.
@renatonascalves I had some more time to think about this and I see the issue you are describing more clearly now. What I think we should do is:
update_option
). This way we do not need to perform an extra query on the frontend of the site, we only need to check an option value.has_homepage
function to just return the value of this option.return (bool) get_option( 'has_published_homepage', false );
This should keep things very performant while also ensure we are not modifying the query when there is not a published homepage.
@kjbenk This is a much better solution. The only downside is that the option keeps there in the database even after the last created homepage is deleted. It is not a big deal though and it doesn't affect the homepage (custom or otherwise).
This fixes a bug where if you don't have a published homepage but you have a draft one, the front-end just fails and shows a not found page.
A common scenario exists when one is crafting a new homepage. Before, the front-end would just break.
Ticket created after the fact: https://alleyinteractive.atlassian.net/browse/DELTA-975