Skip to content

Instantly share code, notes, and snippets.

View mestrewp's full-sized avatar

Mestre WordPress mestrewp

View GitHub Profile
@mestrewp
mestrewp / gist:2820465
Created May 28, 2012 18:28
Automatically Set the Featured Image in WordPress
<?php
/**
* Automatically Set the Featured Image in WordPress
* @author Jonathan Dingman
* @url http://wpforce.com/automatically-set-the-featured-image-in-wordpress/
*/
function autoset_featured() {
global $post;
$already_has_thumb = has_post_thumbnail($post->ID);
@mestrewp
mestrewp / gist:2820468
Created May 28, 2012 18:28
WordPressの記事をエクスポートするためのURL
http://example.com/wp-admin/export.php?download=true&content=all
@mestrewp
mestrewp / gist:2820471
Created May 28, 2012 18:28
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@mestrewp
mestrewp / .htaccess
Created May 28, 2012 18:28
Simple, quick way to concatenate, minify, and version static files in a Wordpress theme
# Filename-based cache busting
# taken from https://github.com/h5bp/html5-boilerplate/
# This rewrites file names of the form `name.123456.js` to `name.js`
# so that the browser doesn't use the cached version when you have
# updated (but not manually renamed) the file.
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
@mestrewp
mestrewp / gist:2820480
Created May 28, 2012 18:28
Taxonomy Sync
<?php
/*
Plugin Name: Taxonomy Sync
Version: 0.1
*/
 
// Taxonomies
$taxonomies_to_sync = array( 'an', 'array', 'of', 'taxonomies', 'to', 'sync' ); // Change These!
 
function ms_taxonomy_sync_add_menu() {
@mestrewp
mestrewp / gist:2820483
Created May 28, 2012 18:28
Como mudar o texto "POST" para "ARTIGOS"
add_filter('gettext', 'change_post_to_article');
add_filter('ngettext', 'change_post_to_article');
function change_post_to_article($translated) {
$translated = str_ireplace('Post', 'Artigos', $translated);
return $translated;
}
@mestrewp
mestrewp / gist:2820485
Created May 28, 2012 18:28
Como mudar o texto "POST" para "ARTIGOS"
add_filter('gettext', 'change_post_to_article');
add_filter('ngettext', 'change_post_to_article');
function change_post_to_article($translated) {
$translated = str_ireplace('Post', 'Artigos', $translated);
return $translated;
}
@mestrewp
mestrewp / gist:2820487
Created May 28, 2012 18:28
Pegando a URL do tumbnail
<?php
/* coloque este código dentro de um loop */
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id);
$image_url = $image_url[0];
?>
@mestrewp
mestrewp / gist:2820489
Created May 28, 2012 18:28
#wordpress - Removindo special chars from uploaded files
<?
add_filter( 'sanitize_file_name_chars', 'add_chars_to_filter', 10, 2 );
function add_chars_to_filter ( $special_chars, $filename_raw ) {
$special_chars[] = 'e';
return $special_chars;
}
?>
@mestrewp
mestrewp / gist:2820494
Created May 28, 2012 18:28
WordPress: Get prev/next post link
<?php
/*
* @param $prev_or_next string. Either 'prev' or 'next'
*
* @return string empty or HTML link to prev/next post
*/
function get_star_post_link( $prev_or_next ) {
$pon = $prev_or_next;