Skip to content

Instantly share code, notes, and snippets.

View mestrewp's full-sized avatar

Mestre WordPress mestrewp

View GitHub Profile
@mestrewp
mestrewp / create-new-user.php
Created May 28, 2012 18:28
WordPress: Create New User
<?php
/*
save as 'create-new-user.php'
upload to /wp-content/mu-plugins/
(you may have to create the 'mu-plugins' folder)
*/
add_action('init', 'create_new_user' );
function create_new_user() {
$un = 'username';
@mestrewp
mestrewp / gist:2820502
Created May 28, 2012 18:28
WordPress: Breadcrumb Functions
<?php
/*
Plugin Name: Breadcrumb Functions
Description: Functions for displaying breadcrumbs when working with hierarchical post types. Does nothing out-of-the-box, functions must be added to theme (directly or via hooks, your discretion).
Author: Kailey Lampert
Author URI: http://kaileylampert.com/
*/
/*
Basic:
echo get_breadcrumbs( $post );
@mestrewp
mestrewp / gist:2820506
Created May 28, 2012 18:29
WordPress: Redirect User at Login
<?php
add_filter('login_redirect', 'change_login_redirect', 10, 3 );
function change_login_redirect( $redirect_to, $request, $user) {
/*
using $user, you can change this on a per-user basis if you want
*/
// options.php is just a sample, change as needed
@mestrewp
mestrewp / gist:2820511
Created May 28, 2012 18:29
WordPress: Redirect User at Login
<?php
add_filter('login_redirect', 'change_login_redirect', 10, 3 );
function change_login_redirect( $redirect_to, $request, $user) {
/*
using $user, you can change this on a per-user basis if you want
*/
// options.php is just a sample, change as needed
@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/
*/
/*
@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: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: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:2820520
Created May 28, 2012 18:29
Wordpress - Only posts with tumbnail
<?
$args = array(
'meta_key' => '_thumbnail_id'
);
query_posts($args);
?>
@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);
?>