Skip to content

Instantly share code, notes, and snippets.

/**
* Sage required files
*
* The mapped array determines the code library included in your theme.
* Add or remove files to the array as needed. Supports child theme overrides.
*/
array_map(function ($file) use ($sage_error) {
$file = "../app/{$file}.php";
if (!locate_template($file, true, true)) {
$sage_error(sprintf(__('Error locating <code>%s</code> for inclusion.', 'sage'), $file), 'File not found');
@Sanabria
Sanabria / front-page.php
Created September 13, 2023 18:08 — forked from lmartins/front-page.php
WooCommerce custom loop for Featured Products
<?php
$args = array(
'post_type' => 'product',
'meta_key' => '_featured',
'meta_value' => 'yes',
'posts_per_page' => 6
);
$featured_query = new WP_Query( $args );
if ($featured_query->have_posts()) :
?>
@Sanabria
Sanabria / Wordpress: Do if the_content is not empty
Created September 15, 2023 03:36 — forked from bhongy/Wordpress: Do if the_content is not empty
Wordpress: Check if the_content is empty / do something only when the_content is empty
<?php if ( get_the_content() ) { ?>
// do or output something
<?php } ?> // break php tag for HTML block
@Sanabria
Sanabria / woo_cart_has_virtual_product.php
Created September 16, 2023 03:02 — forked from smeric/woo_cart_has_virtual_product.php
Check if the WooCommerce cart contains virtual product
<?php
/**
* Check if the cart contains virtual product
*
* @return bool
*/
function woo_cart_has_virtual_product(){
global $woocommerce;
// By default, no virtual product
JOSEPH: Did I hear a dog? What's your dog's name?
+ CONWAY: His name is Homer.
~ dog_name = "Homer"
JOSEPH: Bit of a shuffle or a drag in Homer's step — kind of an old one isn't he?
+ CONWAY: Her name is Blue.
~ dog_name = "Blue"
JOSEPH: Blue sounds like a sweet old hound. I used to know a dog like that.