Skip to content

Instantly share code, notes, and snippets.

Avatar

César Ribeiro chrdesigner

View GitHub Profile
View custom_values_wpautop.php
<?php if(get_post_custom_values('SEU-CUSTOM-FILD')) { foreach(get_post_custom_values('SEU-CUSTOM-FILD') as $suavarivel) { echo wpautop($suavarivel); } } ?>
View README.md
@chrdesigner
chrdesigner / show-sigle-cat-title
Created Aug 16, 2013
Essa função mostra o nome da categoria referente ao post que esta cadastrado.
View show-sigle-cat-title
<?php global $post; $category = get_the_category($post->ID); echo $category[0]->name; ?>
@chrdesigner
chrdesigner / list-tag-wordpress
Last active Dec 21, 2015
Listagem de tags com o título e o link para Wordpress
View list-tag-wordpress
<ul>
<?php $tags = get_the_tags(); foreach ( (array) $tags as $tag ) { echo '<li><a href="' . get_tag_link($tag->term_id) . '" title="' . $tag->name . '">' . $tag->name . '</a></li>';}?>
</ul>
@chrdesigner
chrdesigner / list-link-manager
Created Aug 15, 2013
Em "ID-CATEGORIA" adicionar o ID correto da sua galeria de links.
View list-link-manager
@chrdesigner
chrdesigner / functions.php
Last active Dec 12, 2015
Transform HEX to RGB with PHP
View functions.php
<?php
function hex2RGB($hex) {
$hex = str_replace("#", "", $hex);
if(strlen($hex) == 3) {
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
} else {
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
@chrdesigner
chrdesigner / main.js
Created Oct 11, 2015
jQuery: addClass in <html> if size bellow 415
View main.js
var $window = $(window), $html = $('html');
$window.resize(function resize(){
if ($window.width() < 415) {
return $html.addClass('mobile');
}
$html.removeClass('mobile');
}).trigger('resize');
@chrdesigner
chrdesigner / functions.php
Last active Sep 4, 2015
Function - Disable Checkout for some Countries and States
View functions.php
<?php
/*
* Function - Disable Checkout for some Countries and States
*/
function wc_checkout_validation() {
$shipping_country = ! empty( $_POST['shipping_country'] ) ? $_POST['shipping_country'] : $_POST['billing_country'];
$shipping_state = ! empty( $_POST['shipping_state'] ) ? $_POST['shipping_state'] : $_POST['billing_state'];
// Add here States : More example look here -> wp-content/plugins/woocommerce/i18n/states/
@chrdesigner
chrdesigner / functions.php
Created Aug 21, 2015
WordPress - Search in Specific Post Type
View functions.php
<?php
/*
* Search in Specific Post Type
*/
function search_specific_post_type($query) {
if ($query->is_search) {
$query->set('post_type', array('post'));
};
return $query;
};
View functions.php
<?php
/*
* Add Stock Quantity in Catalog Loop
*/
function odin_stock_catalog() {
global $product;
if ( $product->is_in_stock() ) {
echo '<div class="stock" >' . $product->get_stock_quantity() . __( 'EM ESTOQUE', 'odin' ) . '</div>';
} else {
echo '<div class="out-of-stock" >' . __('SEM ESTOQUE', 'odin' ) . '</div>';
You can’t perform that action at this time.