Skip to content

Instantly share code, notes, and snippets.

View claudiosanches's full-sized avatar
👨‍💻

Claudio Sanches claudiosanches

👨‍💻
View GitHub Profile
@claudiosanches
claudiosanches / functions.php
Created May 28, 2012 16:34
Wordpress - Remove website field from the comments form
<?php
// adicionar isso no functions.php
function dfw_remove_website_field($field) {
if(isset($field['url'])) {
unset($field['url']);
}
return $field;
}
add_filter('comment_form_default_fields', 'dfw_remove_website_field');
?>
@claudiosanches
claudiosanches / .htaccess
Created May 29, 2012 00:51
Aprenda como modicar o endereço da pasta de mídia do Wordpress.org
RedirectMatch 301 ^/wp-content/uploads/(.*)$ http://midia.seudominio.com/$1
@claudiosanches
claudiosanches / transition.html
Created June 6, 2012 22:33
Input with CSS3 transition
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Input with CSS3 transition</title>
<style>
#search {
width: 150px;
-webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
@claudiosanches
claudiosanches / functions.php
Created June 29, 2012 04:36
Order post by modified date - Wordpress
// Order post by modified date
function dfw_query_orderby_modified($query) {
if (is_home() || is_home() && is_paged()) {
$query->query_vars['orderby'] = 'modified';
return;
}
}
add_filter('pre_get_posts', 'dfw_query_orderby_modified');
@claudiosanches
claudiosanches / index.php
Created June 29, 2012 04:44
Display modified date - Wordpress
<!-- Mostra a data como: 28/06/2012 às 01h44 -->
<div class="entry-modified-data"><?php the_modified_date('d/m/Y \à\s H\hi'); ?></div>
@claudiosanches
claudiosanches / wp-config.php
Created July 19, 2012 01:04
Arrumar endereço do Wordpress e home
<?php
// Colocar isso daqui no wp-config.php:
define('WP_SITEURL', 'http://example.com/wordpress');
define('WP_HOME', 'http://example.com/wordpress');
// não esqueça de arrumar os endereços para o seu
@claudiosanches
claudiosanches / functions.php
Created July 21, 2012 06:36
Wordpress pagination
<?php
/**
* Pagination.
*/
function dfw_pagination() {
global $wp_query;
$total_pages = $wp_query->max_num_pages;
if ($total_pages > 1) {
$current_page = max( 1, get_query_var( 'paged' ) );
@claudiosanches
claudiosanches / functions.php
Created July 24, 2012 03:22
Wordpress Related Posts function
<?php
/**
* Related Posts.
*
* Usage:
* To show related by categories:
* Add in single.php <?php dfw_related_posts(); ?>.
* To show related by tags:
* Add in single.php <?php dfw_related_posts('tag'); ?>.
@claudiosanches
claudiosanches / placeholder.js
Created August 2, 2012 17:42
Placeholder support
jQuery(document).ready(function($) {
$('input[placeholder]').each(function() {
var ph = $(this).attr('placeholder');
$(this).val(ph).focus(function() {
if($(this).val() == ph) {
$(this).val('');
}
}).blur(function(){
if(!$(this).val()) {
$(this).val(ph);
@claudiosanches
claudiosanches / functions.php
Created August 8, 2012 00:31
Slideshow with metabox, custom field and query_posts
<?php
// Add metabox
function dfw_slideshow_metabox() {
add_meta_box(
'dfw-metabox',
'Slideshow',
'dfw_slideshow_metabox_content',
'post',
'side'
);