Skip to content

Instantly share code, notes, and snippets.

View mestrewp's full-sized avatar

Mestre WordPress mestrewp

View GitHub Profile
@mestrewp
mestrewp / require wp-config
Created May 28, 2012 18:29
Se você esta escrevendo um programa fora da estrutura padrão do wordpress e precisa conectar ao banco de dados, não esquece que requerer este três arquivos
<?php
include_once("wp-config.php");
include_once("wp-load.php");
include_once("wp-includes/wp-db.php");
?>
@mestrewp
mestrewp / gist:2820526
Created May 28, 2012 18:29
WordPress - Configurando constantes para acesso ao FTP pelo WordPress
<?php
/**
* @author marcelo toscano <marcelo@toscano.com.br>
* Essas configurações vão dentro dentro do wp-config.php
*/
//define o usuário
define('FTP_USER','usuario');
//define a senha
define('FTP_PASS','senha');
//define qual seu host
@mestrewp
mestrewp / EmptyWidget.php
Created May 28, 2012 18:29
Plugin code to create a single widget in wordpress.
<?php
/**
* @package RedRokk
* @version 1.0.0
*
* Plugin Name: Empty Widget
* Description: Single Widget Class handles all of the widget responsibility, all that you need to do is create the html. Just use Find/Replace on the Empty_Widget keyword to rebrand this class for your needs.
* Author: RedRokk Interactive Media
* Version: 1.0.0
* Author URI: http://www.redrokk.com
@mestrewp
mestrewp / CTP_custom_post_per_page.php
Created May 28, 2012 18:29
CTP custom post per page
<?php
// Posts per page on CPT
function cs_custom_posts_per_page_CPT( $query ) {
switch ( $query->query_vars['post_type'] ) {
case 'album-de-fotos':
$query->query_vars['posts_per_page'] = 9;
break;
case 'loja':
$query->query_vars['posts_per_page'] = 15;
break;
@mestrewp
mestrewp / gist:2820522
Created May 28, 2012 18:29
Wordpress - show child pages
<? // reference http://codex.wordpress.org/Function_Reference/wp_list_pages
$args = array(
'depth' => 1,
'date_format' => get_option('date_format'),
'child_of' => get_the_ID(),
'title_li' => __(''),
'echo' => 1);
wp_list_pages($args);
?>
@mestrewp
mestrewp / gist:2820520
Created May 28, 2012 18:29
Wordpress - Only posts with tumbnail
<?
$args = array(
'meta_key' => '_thumbnail_id'
);
query_posts($args);
?>
@mestrewp
mestrewp / gist:2820518
Created May 28, 2012 18:29
WordPress - Only show posts with featured_image
<?
//change showposts for posts-per-page if you a are running a newest version of wordpress
$args = array('showposts' => 10,'meta_query' => array(array('key' => 'featured_image','value' => '','compare' => '!=')));
$result = new WP_Query( $args );
?>
@mestrewp
mestrewp / gist:2820517
Created May 28, 2012 18:29
show only posts with featured_image
<?
//change showposts for posts-per-page if you a are running a newest version of wordpress
$args = array('showposts' => 10,'meta_query' => array(array('key' => 'featured_image','value' => '','compare' => '!=')));
$result = new WP_Query( $args );
?>
@mestrewp
mestrewp / gist:2820515
Created May 28, 2012 18:29
css para fundo flexivel
background: url(images/image.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-color:#ffffff;
@mestrewp
mestrewp / gist:2820513
Created May 28, 2012 18:29
WordPress: Custom Field Shortcodes
<?php
/*
Plugin Name: Custom Field Shortcodes
Plugin URI: http://trepmal.com/2010/12/including-custom-fields-inside-your-post/
Description: Include a custom field in your post with a shortcode. [cf name=custom_field]
Author: Kailey Lampert
Version: 1.0
Author URI: http://kaileylampert.com/
*/
/*