<?php
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');
?>
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 | |
/** | |
* Translate post-type-archive-slug when different from post-type-slug. | |
* | |
* You can have your archive slug set to, for example /books and the singles on /book/title by setting | |
* $args['rewrite'] => [ 'slug' => 'book', ... ]; | |
* $args['has_archive'] => 'books'; | |
* when registering your post_type | |
* |
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
function equalHeight(element) { | |
var currentTallest = 0, | |
currentRowStart = 0, | |
rowDivs = new Array(), | |
$el, | |
topPosition = 0; | |
$(element).each(function() { | |
$el = $(this); |
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 | |
//AJAX ADD TO CART BUTTON | |
$product_id = 143; | |
if( !my_custom_cart_contains( $product_id ) ) { | |
?> | |
<button class="my-custom-add-to-cart-button" data-product-id="<?php echo $product_id; ?>">add to cart</button> | |
<?php | |
} else { | |
?> |
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' => array( 'product' ), | |
'meta_key' => 'total_sales', | |
'orderby' => 'meta_value_num', | |
'order' => 'desc', | |
'posts_per_page' => 5 | |
); | |
$popular_products = new WP_Query( $args ); |
Thanks and credit to mattn and ferreus on GitHub.
Also check out Developing on WSL and/or wslpath
(Windows 10 Build 17046 or later) if you're using the Windows Subsystem for Linux.
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 | |
/** | |
* Disable jQuery Migrate in WordPress. | |
* | |
* @author Guy Dumais. | |
* @link https://en.guydumais.digital/disable-jquery-migrate-in-wordpress/ | |
*/ | |
add_filter( 'wp_default_scripts', $af = static function( &$scripts) { | |
if(!is_admin()) { | |
$scripts->remove( 'jquery'); |
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 | |
global $wp_query; | |
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; | |
$prev_text = __('Newer Posts'); | |
$next_text = __('Older Posts'); | |
// The magic happens here. First we grab the URL and check it for URL params, |
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
/*********************************************************************************************/ | |
/** Get the total sum (money spent) of orders made by a user with a "complete" status in WooCommerce. This will output the current month's sum of all orders made by the customer. **/ | |
/*********************************************************************************************/ | |
<?php | |
function current_customer_month_count( $user_id=null ) { | |
if ( empty($user_id) ){ | |
$user_id = get_current_user_id(); | |
} |
NewerOlder