Snippets frequently used with Sage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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()) : | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( get_the_content() ) { ?> | |
// do or output something | |
<?php } ?> // break php tag for HTML block |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Check if the cart contains virtual product | |
* | |
* @return bool | |
*/ | |
function woo_cart_has_virtual_product(){ | |
global $woocommerce; | |
// By default, no virtual product |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
OlderNewer