Skip to content

Instantly share code, notes, and snippets.

Avatar

Mandi Wise mandiwise

  • Edmonton, Canada
View GitHub Profile
View gist:f60fb50838edabd49159
add_filter( 'the_content', function( $content ) {
$response = wp_remote_get( 'http://ben.lobaugh.net/wp-json/posts' );
if( '200' == wp_remote_retrieve_response_code( $response ) ) {
$posts = json_decode( wp_remote_retrieve_body( $response ) );
foreach( $posts AS $p ) {
echo $p->title->rendered . "<br/>";
@spivurno
spivurno / gist:3710653
Created Sep 12, 2012
Gravity Wiz // Limit IP to One Submission Per Time Period
View gist:3710653
<?php
/**
* Limit IP to One Submission Per Time Period
* http://gravitywiz.com/2012/05/12/limit-ip-to-one-submission-per-time-period
*/
$gws_limit_message = 'You may only submit this form once every 24 hours.';
$gws_limit_time = 86400; // must be specified in seconds; 86400 seconds is equal to 24 hours
View unregister post type wordpress
<?php
/*
* Usage for a custom post type named 'movies':
* unregister_post_type( 'movies' );
*
* Usage for the built in 'post' post type:
* unregister_post_type( 'post', 'edit.php' );
*/
function unregister_post_type( $post_type, $slug = '' ){
@spivurno
spivurno / gw-disable-html5-validation.php
Last active Mar 30, 2016
Gravity Wiz // Disable HTML5 Validation on Gravity Forms
View gw-disable-html5-validation.php
<?php
/**
* Gravity Wiz // Disable HTML5 Validation on Gravity Forms
* http://gravitywiz.com/disable-html5-validation-on-gravity-forms/
*/
add_filter( 'gform_form_tag', 'add_no_validate_attribute_to_form_tag' );
function add_no_validate_attribute_to_form_tag( $form_tag ) {
return str_replace( '>', ' novalidate="novalidate">', $form_tag );
}
@dannyockilson
dannyockilson / gist:52a444195f0df873cc1c
Created Mar 13, 2015
Simple Angular Service for WordPress
View gist:52a444195f0df873cc1c
'use strict';
angular.module('wordpress', [])
.service( 'wpService',
function($http, $q){
var url = 'http://allin.local/wp-json/';
return({
@eteubert
eteubert / abstract-example.php
Created Oct 31, 2011
WordPress: Customize Page & Post Metaboxes
View abstract-example.php
<?php
$wp_meta_boxes[ 'post' ][ 'normal' ][ 'core' ][ 'post excerpt' ][ 'title' ] = 'Abstract';
$wp_meta_boxes[ 'post' ][ 'normal' ][ 'core' ][ 'post excerpt' ][ 'id' ] = 'postabstract';
@annalinneajohansson
annalinneajohansson / order_by_multiple_meta_values.php
Last active Jan 17, 2018
Solution to order posts by two different meta values (the same way ORDER val1, val2 would with SQL) http://wordpress.stackexchange.com/a/67391/5045
View order_by_multiple_meta_values.php
<?php
/*
* Solution to order first by date, then by start time (both are meta values)
* http://wordpress.stackexchange.com/a/67391/5045
* */
add_action( 'pre_get_posts', 'pre_get_posts_programpunkter' );
function pre_get_posts_programpunkter( $query ) {
if( !is_admin() && is_post_type_archive( 'programpunkt' ) && $query->is_main_query() ) {
@nachiket-p
nachiket-p / meteor_servercall.html
Created Jun 21, 2012
Meteor: Calling server method from client
View meteor_servercall.html
<head>
<title>meteor_servercall</title>
</head>
<body>
{{> simple}}
{{> passData}}
</body>
<template name="simple">
@crondeau
crondeau / chilpages-looping.php
Last active Nov 2, 2018
I used this code to loop through child pages of a custom post type called work. Each Work piece had a title, featured image and pdf. The child pages, describe the details of the project or work piece and display as an accordion. So basically what we have is an accordion within an accordion.
View chilpages-looping.php
<?php
// loop through the sub-pages of your custom post type
$childpages = new WP_Query( array(
'post_type' => 'work',
'post_parent' => $this_page,
'posts_per_page' => 100,
'orderby' => 'menu_order'
));
while ( $childpages->have_posts() ) : $childpages->the_post(); ?>
@spivurno
spivurno / gw-gravity-forms-random-field-order.php
Last active Apr 16, 2019
Gravity Wiz // Gravity Forms // Random Field Order
View gw-gravity-forms-random-field-order.php
<?php
/**
* Gravity Wiz // Gravity Forms // Random Fields
*
* Randomly display a specified number of fields on your form.
*
* @version 1.1
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
* @link https://gravitywiz.com/random-fields-with-gravity-forms/
You can’t perform that action at this time.