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
wp post update --post_category=sample $(wp post list --cat=1 --format=ids) |
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 | |
// Replace the https://livesite.com/ with actual URL | |
add_filter( 'wp_get_attachment_url', function( $url, $attachment_id ) { | |
return str_replace( home_url(), 'https://livesite.com/', $url ); | |
}, 99, 2 ); | |
// Replace the https://livesite.com/ with actual URL | |
add_filter( 'wp_get_attachment_image_src', function( $image, $attachment_id ) { | |
$image[0] = str_replace( home_url(), 'https://livesite.com/', $image[0] ); |
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
wp post list --post_type=post --format=ids | xargs -0 -d ' ' -I % wp post meta add % _thumbnail_id <thumb_id> |
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
wp post delete $(wp post list --post_type='product' --post_status=trash --format=ids) |
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 | |
function get_ordered_list_of_attributes(){ | |
global $product; | |
$formatted_attributes = array(); | |
$attributes = $product->get_attributes(); | |
foreach($attributes as $attr=>$attr_deets){ |
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 | |
/* Add the field to the checkout */ | |
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field'); | |
function my_custom_checkout_field( $checkout ) { | |
echo '<div id="my_custom_checkout_field"><h3>'.__('My Field').'</h3>'; | |
woocommerce_form_field( 'p_trade', array( |
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 | |
/* Usage: Put [bacs_account_details] shortcode in "WooCommerce > Settings > Checkout > BACS > Description field" */ | |
/* This function outputs the BACS account details */ | |
function list_bacs_accounts() { | |
$accounts = get_option( 'woocommerce_bacs_accounts'); | |
if ( $accounts ) { | |
$list_accounts = '<table> | |
<thead> |
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
add_action( 'pre_get_posts', 'users_own_attachments'); | |
function users_own_attachments( $wp_query_obj ) | |
{ | |
global $current_user, $pagenow; | |
if ( $pagenow == 'upload.php' || ( $pagenow == 'admin-ajax.php' && !empty( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'query-attachments' ) ) { | |
$wp_query_obj->set( 'author', $current_user->ID ); | |
} | |
} |
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 | |
$term = get_query_var( 'category_name' ); | |
echo "<h2>" . $term . "</h2>"; | |
query_posts(array( 'post_type'=>'post', 'category' => $term, 'posts_per_page' => -1 )); | |
if ( have_posts() ) : while ( have_posts() ) : the_post(); | |
echo "<h2>" . the_title() . "</h2>"; | |
echo "<section>". the_content(). "</section>"; | |
print apply_filters( 'taxonomy-images-list-the-terms', '' ); | |
endwhile; else: | |
echo "<h3> Sorry, no matched your criteria</h3>"; |