Skip to content

Instantly share code, notes, and snippets.

View mizner's full-sized avatar

Michael Mizner mizner

View GitHub Profile
@mizner
mizner / wp-query-posts-per-page-by-category.php
Created April 18, 2016 05:19
WP Query posts per page by category
<?php
$the_query = new WP_Query(array(
'category_name' => 'featured',
'posts_per_page' => '3'
));
while ($the_query->have_posts()) : $the_query->the_post(); ?>
<div class="post-container">
<?php the_post_thumbnail( 'medium' ) ?>
<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
<p><?php the_excerpt(); ?></p>
@mizner
mizner / app.jsx
Created April 24, 2016 13:15
Working React Fetch WP API list of pages
import 'bootstrap/dist/css/bootstrap.min.css';
import React from 'react';
import ReactDOM from 'react-dom';
import 'whatwg-fetch';
export class Posts extends React.Component {
constructor(){
super(...arguments);
this.state = {
Posts: []
@mizner
mizner / Simple Ajax Login Form.php
Created May 18, 2016 14:10 — forked from cristianstan/Simple Ajax Login Form.php
Wordpress: Simple Ajax Login Form
<?php
//Simple Ajax Login Form
//Source: http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way/
//html
<form id="login" action="login" method="post">
<h1>Site Login</h1>
<p class="status"></p>
<label for="username">Username</label>
<input id="username" type="text" name="username">
@mizner
mizner / wp-query-cpt.php
Last active January 9, 2017 14:09
Wordpress Query Custom Post Type (Testimonial)
<?php
$the_query = new WP_Query( array(
'post_type' => 'jetpack-testimonial',
'posts_per_page' => '3'
) );
while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="testimonial">
<h4><?php echo the_title(); ?></h4>
<?php echo the_content(); ?>
</div>
@mizner
mizner / expecting.md
Created May 26, 2016 20:41 — forked from ksafranski/expecting.md
Basic principles of using tcl-expect scripts

Intro

TCL-Expect scripts are an amazingly easy way to script out laborious tasks in the shell when you need to be interactive with the console. Think of them as a "macro" or way to programmaticly step through a process you would run by hand. They are similar to shell scripts but utilize the .tcl extension and a different #! call.

Setup Your Script

The first step, similar to writing a bash script, is to tell the script what it's executing under. For expect we use the following:

#!/usr/bin/expect
@mizner
mizner / cpt-query-filter-listjs.php
Created May 30, 2016 01:36
Custom Post Type & Tax w/ List JS
<section class="auctions row container">
<h1><?php $post_type = get_post_type_object( 'auctions_post' );
echo $post_type->label; ?></h1>
<div id="auctions-list">
<input class="search" placeholder="Filter Auctions"/>
<ul class="sort-by">
<button class="sort btn" data-sort="name">Sort by name</button>
<button class="sort btn" data-sort="date">Sort by date</button>
</ul>
<h3>Term List</h3>
@mizner
mizner / acf-future-posts.php
Created May 31, 2016 02:28 — forked from aderaaij/acf-future-posts.php
Advanced Custom Fields datepicker: Show only events with a date of today or in the future. Extra comments from Pasnon @ ACF Forums: f you needed to, you could also play with the comparison date, which is the first array in meta_query, currently set to date("Y-m-d") which is today; if you were to make it date("Y-m-d", strtotime("-1 day")) you cou…
<?php
/*
* Display posts only from today and in the future:
* http://old.support.advancedcustomfields.com/discussion/6000/how-to-sort-posts-by-acf-date-and-display-only-future-posts
* by Pasnon
*/
$date_args = array(
'post_type' => 'events',
@mizner
mizner / plugin.php
Created June 26, 2016 19:32 — forked from logoscreative/plugin.php
Friendlier, Safer WordPress Admin Areas
<?php
/**
* "Friendlier, Safer WordPress Admin Areas"
* Presented by Cliff Seal at WordCamp Atlanta 2015 and Asheville 2016
* Slides: http://www.slideshare.net/cliffseal/wp-admin
*
* Plugin Name: A Better Admin Experience
* Plugin URI: http://evermoresites.com
* Description: Cleans up and sanitizes the WordPress admin area
* Version: 1.0
@mizner
mizner / WP-CLI-Commands
Created July 22, 2016 09:02 — forked from lukecav/WP-CLI-Commands
WP-CLI - Handy Commands
Search and Replace
https://wp-cli.org/commands/search-replace/
wp search-replace
wp search-replace 'http://example.dev' 'http://example.com'
Optmize database
https://wp-cli.org/commands/db/optimize/
Repair database
http://wp-cli.org/commands/db/repair/
@mizner
mizner / enable-all-post-types.php
Last active August 2, 2016 03:25
Gravity Forms + Custom Post Type (enable all post types)
<?php
add_filter( 'gfcpt_post_type_args', 'my_gf_post_type_args' );
function my_gf_post_type_args( $args ) {
$args['public'] = false;
return $args;
}