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 | |
$query = new WP_Query(array( | |
'post_type' => 'custom_post', | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'custom_taxonomy', | |
'field' => 'slug', | |
'terms' => 'taxonomy-slug' | |
) | |
) |
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 | |
var_dump( wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ) ) ); | |
/* | |
array(4) { | |
[0]=> | |
string(81) "http://url/wp-content/uploads/2017/05/img-90x180.jpg" | |
[1]=> | |
int(90) | |
[2]=> |
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
SELECT | |
DATE_FORMAT(column,'%d/%m/%Y') | |
FROM table |
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
SELECT * | |
FROM ( | |
table1 INNER JOIN table2 | |
ON table1.column1 = table2.column1 | |
) | |
INNER JOIN table3 | |
ON table1.column2 = table3.column1 |
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
UPDATE table_name | |
SET column_name = REPLACE( | |
column_name, | |
'search', | |
'replace' | |
) |
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 | |
// https://br.wordpress.org/plugins/really-simple-captcha/ | |
$captcha_instance = new ReallySimpleCaptcha(); | |
$captcha_instance->bg = array( 255, 255, 255 ); | |
$word = $captcha_instance->generate_random_word(); | |
$prefix = mt_rand(); | |
$img_captcha = $captcha_instance->generate_image( $prefix, $word ); | |
if ( isset( $_POST['send'] ) && $_POST['send'] == 'ok' ) { | |
if ( $captcha_instance->check( $_POST['prefix'], $_POST['captcha'] ) ) { |
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 | |
$cat = get_categories( array( | |
'taxonomy' => 'product_tag' | |
) ); | |
foreach( $cat as $key => $value ){ | |
var_dump( get_field( 'imagem', 'product_tag_'.$value->term_id ) ); | |
echo get_term_link( $value->term_id, 'product_tag' ); | |
} |
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 | |
// Change number or products per row to 3 | |
add_filter('loop_shop_columns', 'loop_columns'); | |
if (!function_exists('loop_columns')) { | |
function loop_columns() { | |
return 3; // 3 products per row | |
} | |
} |
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_action( 'init', 'register_new_post_type' ); | |
function register_new_post_type(){ | |
$args = array( | |
'label' => 'Post title', | |
'show_ui' => true, | |
'public' => true, | |
'hierarchical' => true, | |
'has_archive' => true, | |
'supports' => array( 'title' ), |
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 | |
/* Customize Product Categories Labels */ | |
add_filter( 'woocommerce_taxonomy_args_product_cat', 'custom_wc_taxonomy_args_product_cat' ); | |
function custom_wc_taxonomy_args_product_cat( $args ) { | |
$args['label'] = __( 'Product Categories', 'woocommerce' ); | |
$args['labels'] = array( | |
'name' => __( 'Product Categories', 'woocommerce' ), | |
'singular_name' => __( 'Product Category', 'woocommerce' ), | |
'menu_name' => _x( 'Categories', 'Admin menu name', 'woocommerce' ), | |
'search_items' => __( 'Search Product Categories', 'woocommerce' ), |