Skip to content

Instantly share code, notes, and snippets.

View chrdesigner's full-sized avatar

César Ribeiro chrdesigner

View GitHub Profile
@chrdesigner
chrdesigner / list-tag-wordpress
Last active December 21, 2015 03:48
Listagem de tags com o título e o link para 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 August 15, 2013 20:19
Em "ID-CATEGORIA" adicionar o ID correto da sua galeria de links.
@chrdesigner
chrdesigner / show-sigle-cat-title
Created August 16, 2013 13:31
Essa função mostra o nome da categoria referente ao post que esta cadastrado.
<?php global $post; $category = get_the_category($post->ID); echo $category[0]->name; ?>
<?php if(get_post_custom_values('SEU-CUSTOM-FILD')) { foreach(get_post_custom_values('SEU-CUSTOM-FILD') as $suavarivel) { echo wpautop($suavarivel); } } ?>
@chrdesigner
chrdesigner / show_future_post.php
Last active December 29, 2015 10:29
Display posts with 'future' status
<?php
add_filter('the_posts', 'show_future_posts');
function show_future_posts($posts)
{
global $wp_query, $wpdb;
if(is_single() && $wp_query->post_count == 0)
{
$posts = $wpdb->get_results($wp_query->request);
<?php
global $post;
$trim_length = 450; //desired length of text to display
$summary_excerpt = 'wpcf-breve-descricao';
$value = get_post_meta($post->ID, $summary_excerpt, true);
if ($value != '') {
if(strlen($value) <= $trim_length){
echo apply_filters('breve-descricao', $value);
} else {
echo apply_filters('breve-descricao', rtrim(substr($value,0,$trim_length)).'...');
@chrdesigner
chrdesigner / function.php
Last active August 29, 2015 14:02
add rel prettyphoto to all images
<?php
/* add rel prettyphoto to all images */
function autoadd_rel_prettyPhoto($content) {
global $post;
$pattern = "/(<a(?![^>]*?data-rel=['\"]prettyPhoto.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png)['\"][^\>]*)>/i";
$replacement = '$1 data-rel="prettyPhoto['.$post->ID.']">';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
add_filter("the_content","autoadd_rel_prettyPhoto");
@chrdesigner
chrdesigner / functions.php
Created August 27, 2014 19:16
Custom Add To Cart Messages
<?php
add_filter( 'wc_add_to_cart_message', 'custom_add_to_cart_message' );
function custom_add_to_cart_message( $product_id ) {
$product_id = $_REQUEST[ 'product_id' ];
if ( is_array( $product_id ) ) {
$titles = array();