Hi Olafsosh,
Thanks so much for reaching out and reporting this issue. I’m here to help!
Do you recall if a particular snippet had been added before the site started crashing? If so, could you please share with me the snippet?
Let me know and we’ll review this further.
Cheers,
Jeff
The Code Snippets Team
-
This reply was modified 11 months, 2 weeks ago by
Jeff Mankini.
-
This reply was modified 11 months, 2 weeks ago by
Jeff Mankini.
Hey! Sure, no problemo 🙂
I am not completely sure, but most likely it was this:
function add_views_ordering_option( $args, $query ) {
if ( isset( $query->get(‘orderby’) ) && $query->get(‘orderby’) === ‘views’ ) {
$args[‘meta_key’] = ‘post_views_count’;
$args[‘orderby’] = ‘meta_value_num’;
}
return $args;
}
add_filter( ‘woocommerce_get_catalog_ordering_args’, ‘add_views_ordering_option’, 10, 2 );
function add_views_orderby_option( $sortby ) {
$sortby[‘views’] = ‘Most Viewed’;
return $sortby;
}
add_filter( ‘woocommerce_default_catalog_orderby_options’, ‘add_views_orderby_option’ );
add_filter( ‘woocommerce_catalog_orderby’, ‘add_views_orderby_option’ );
Hi @olafsosh,
At first glance, I don’t see anything wrong with that specific code, but when your site is broken by a code with issues, you can fix it quickly by adding the following constant in your wp-config.php file (located at the root directory of your WordPress installation), just before the line that reads /* That's all, stop editing! Happy blogging. */:
define( 'CODE_SNIPPETS_SAFE_MODE', true );
See: Help! My site broke! How can I fix it?
Plugin Author
Imants
(@0aksmith)
Hi everyone,
Apologies for the late reply! I hope everything is working properly for you now.
As there hasn’t been any recent activity, I’ll be closing this thread. If you’re still experiencing any issues or have further questions about Code Snippets, please don’t hesitate to let me know.