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 August 27, 2012 23:39
Tradução Wordpress
<?php
add_action( 'after_setup_theme', 'meu_blog_traducao_init' );
function meu_blog_traducao_init() {
load_theme_textdomain( 'nome-do-tema', TEMPLATEPATH . '/languages' );
}
/*
* Strings que irão receber tradução deve estar como:
* <?php _e('Palavra que vai ser traduzida', 'nome-do-tema'); ?>
@claudiosanches
claudiosanches / functions.php
Created August 28, 2012 01:05
Wordpress Metabox with uploader
<?php
// Add metabox
function dfw_slideshow_metabox() {
add_meta_box(
'dfw-metabox',
'Slideshow',
'dfw_slideshow_metabox_content',
'post',
'side'
@claudiosanches
claudiosanches / functions.php
Created August 29, 2012 22:34
Modificar nome e link do logo no wp-login.php
<?php
function meu_wp_login_url() {
return get_bloginfo('url');
}
add_filter('login_headerurl', 'meu_wp_login_url');
function meu_wp_login_title() {
return get_bloginfo('name');
}
add_filter('login_headertitle', 'meu_wp_login_title');
@claudiosanches
claudiosanches / jquery.js
Created September 1, 2012 00:18
Wordpress jQuery
// Errado:
$(document).ready(function() {
// código usando $
}
// Certo:
jQuery(document).ready(function($) {
// código usando $
}
@claudiosanches
claudiosanches / index.php
Created September 5, 2012 15:58
Wordpress custom loop
<?php
// Inicia uma contagem.
$n = 0;
// Cria o loop.
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php if ($n < 2) : ?>
<!-- Seu código para aparecerem as imagens menores -->
<?php get_header(); ?>
<div id="primary">
<section id="content" role="main">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<article <?php post_class(); ?>>
<img src="<?php echo get_option( 'url' );?>/<?php echo get_post_meta( $post->ID, 'post-thumbnails' ,true );?>"
title="<?php the_title();?>" alt="<?php the_title();?>"
width="300px" height="255px">
<a href="<?php the_permalink()?>" title="<?php the_title();?>" alt="<?php the_title();?>"><?php the_title();?></a>
@claudiosanches
claudiosanches / functions.php
Created September 15, 2012 16:46
Custom posts per page for Taxonomy
<?php
/**
* Custom posts per page for Taxonomy
*/
function cs_custom_posts_per_page( $query ) {
if ( is_tax( 'Categorias' ) ) {
$query->query_vars['posts_per_page'] = 1;
return;
@claudiosanches
claudiosanches / index.php
Created September 19, 2012 17:42
Posts per page
<?php
query_posts('cat=-24&posts_per_page=10');
// resto do código...
@claudiosanches
claudiosanches / index.html
Created September 20, 2012 02:25
Menu CSS
<!DOCTYPE html>
<!--[if IE 6]><html id="ie6" dir="ltr" lang="pt-BR"><![endif]-->
<!--[if IE 7]><html id="ie7" dir="ltr" lang="pt-BR"><![endif]-->
<!--[if IE 8]><html id="ie8" dir="ltr" lang="pt-BR"><![endif]-->
<!--[if !(IE 6) | !(IE 7) | !(IE 8)]><!--><html dir="ltr" lang="pt-BR"><!--<![endif]-->
<head>
<meta charset="UTF-8" />
<title>Menu</title>
<style>
@claudiosanches
claudiosanches / functions.php
Created September 20, 2012 03:52
Force Excerpt in Feeds
<?php
/**
* Force Excerpt in Feeds
*
* @param string $content Content of post
*
* @return string Excerpt of post
*/
function cs_feed_force_excerpt( $content ) {