Skip to content

Instantly share code, notes, and snippets.

View renanlara's full-sized avatar

Renan Lara renanlara

View GitHub Profile
@renanlara
renanlara / header.php
Last active May 12, 2018 13:16
WooCommerce - Exibe: Seja bem vindo, faça seu Login ou Cadastre-se! Seja bem vindo, "Usuário" ou Minha Conta!
<?php global $current_user; if ( isset($current_user) ) { echo "Seja bem-vindo, "; echo $current_user->user_login; } ?>
<?php global $user_ID;
if($user_ID) {
echo '<class="login"><a href="' . site_url('minha-conta/logout/', 'login') . '">' . __('(Sair)', 'atahualpa') . '</a>';
} else {
echo '<class="login"><a href="' . site_url('minha-conta/', 'login') . '">' . __('Faça seu Login', 'atahualpa') . '</a>';
} ?>
<?php global $current_user; if ( isset($current_user) ) { echo "ou "; } ?>
<?php global $user_ID;
@renanlara
renanlara / functions.php
Last active December 15, 2015 09:19
WooCommerce - Add new tab in products.
<?php
// Benefícios
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
// Adds the new tab
$tabs['beneficios'] = array(
@renanlara
renanlara / customfields.php
Created March 26, 2013 19:37
Custom Fields
<?php global $post;echo get_post_meta($post->ID, 'name', true);?>
@renanlara
renanlara / functions.php
Last active December 15, 2015 16:59
Search Filter
<?php
// Search Filter xD
function fb_search_filter($query) {
if ( !$query->is_admin && $query->is_search) {
$query->set('post__not_in', array(557,30,4,598,682) ); // id of page or post
}
return $query;
@renanlara
renanlara / functions.php
Created April 17, 2013 14:58
Display 12 products per page.
<?php
// Display 12 products per page.
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 12;' ), 20 );
@renanlara
renanlara / index.php
Created April 17, 2013 15:00
WooCommerce - Sample products loop
<ul class="products">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 12
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
woocommerce_get_template_part( 'content', 'product' );
@renanlara
renanlara / header.php
Last active December 16, 2015 10:29
WooCommerce - Exibe o número de itens do carrinho de compras
<?php global $current_user; if ( isset($current_user) ) { echo "Seja bem-vindo, "; echo $current_user->user_login; } ?>
<?php global $user_ID;
if($user_ID) {
echo '<class="login"><a href="' . site_url('minha-conta/logout/', 'login') . '">' . __('(Sair)', 'atahualpa') . '</a>';
} else {
echo '<class="login"><a href="' . site_url('minha-conta/', 'login') . '">' . __('Faça seu Login', 'atahualpa') . '</a>'; } ?>
<?php global $current_user; if ( isset($current_user) ) { echo "ou "; } ?>
<?php global $user_ID;
if($user_ID) {
@renanlara
renanlara / myphpadmin.sql
Last active November 15, 2016 15:06
Atualizar as URLs no Banco de Dados do WordPress
UPDATE wp_options SET option_value = replace(option_value, 'http://url-antiga.com.br', 'http://url-nova.com.br') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://url-antiga.com.br','http://url-nova.com.br');
UPDATE wp_posts SET post_content = replace(post_content, 'http://url-antiga.com.br', 'http://url-nova.com.br');
@renanlara
renanlara / index.php
Created October 28, 2013 14:37
Show images attached of post
<?php if( have_posts() ) : while( have_posts() ) : the_post();
$posts = get_posts(array(
"showposts" => -1,
"what_to_show" => "posts",
"post_status" => "inherit",
"post_type" => "attachment",
"orderby" => "menu_order",
"order" => "ASC",
"posts_per_page" => 1,
"post_mime_type" => "image/jpeg,image/gif,image/jpg,image/png",
@renanlara
renanlara / file.php
Last active August 29, 2015 13:58
Erro de acentuação no upload de arquivos
<?php
// Edit in "wp-admin\includes\file.php"
// of: if
if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file) ) {
// for: