Skip to content

Instantly share code, notes, and snippets.

César Ribeiro chrdesigner

View GitHub Profile
@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 / 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; ?>
View README.md
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 filter-featured-more-category.php
@chrdesigner
chrdesigner / show_future_post.php
Last active Dec 29, 2015
Display posts with 'future' status
View show_future_post.php
<?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);
View trim-words-meta.php
<?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 Aug 29, 2015
add rel prettyphoto to all images
View function.php
<?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 Aug 27, 2014
Custom Add To Cart Messages
View functions.php
<?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();
You can’t perform that action at this time.