Skip to content

Instantly share code, notes, and snippets.

@bmoredrew
bmoredrew / index.php
Last active Apr 2, 2019 — forked from lepittenger/index.php
Check if the_content is empty
View index.php
<?php
if ( $post->post_content=="" )
{
// do something for posts without content
}
else
{
// do something for posts with content
};
View gist:967e920c5784422e50272969b9336617
.opened ul#mobile_menu {
max-height: 400px;
height: 400px;
overflow-y: scroll;
}
View szbl-login-restriction.php
<?php
/*
Plugin Name: Sizeable Whitelist Login
Author: Sizeable Interactive
Author URI: https://www.sizeableinteractive.com
Version: 0.1
Description: Server agnostic plugin to white list WordPress login screen to IP addresses using a self-authenticating secret URL.
**** NOTE ***
You must define the SZBL_SECRET_LOGIN_URL or set a login URL in the settings page for this plugin to take affect.
View margin-padding-utilities.sass
// Margin and padding classes
// -------------------------
=box-model($direction, $type, $amount, $multiplier)
.#{str-slice($type, 1, 1) + $direction}-#{$amount * $multiplier}
@if $direction == ""
#{$type}: ($amount * $multiplier + px) !important
@if $direction == "t" or $direction == "y"
#{$type}-top: ($amount * $multiplier + px) !important
@bmoredrew
bmoredrew / full-width-breakout.css
Created Jan 12, 2018
Breakout of a parent container
View full-width-breakout.css
.full-width {
width: 100vw;
position: relative;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
}
View WordPress get_the_ID() replacement.md

This extends the built-in WordPress function get_the_ID() to return the post ID both inside and outside the loop.

Used outside the loop (in header.php):

<?php if ( function_exists( 'gt_hide_nav' ) && ! gt_hide_nav() ) : ?>
  <nav role="navigation">
    <?php if ( function_exists( 'bones_main_nav' ) ) bones_main_nav(); ?>
  </nav>
@bmoredrew
bmoredrew / sort-by-acf-repeater-field.php
Last active May 7, 2022
Sort Posts by ACF Repeater Field Using Multidimensional Array
View sort-by-acf-repeater-field.php
<?php
// Create an empty array for storage
$post_data = array();
// Set arguments for your query
$args = array(
'post_type' => 'trips',
'posts_per_page' => 999
);
@bmoredrew
bmoredrew / Arr.php
Created Sep 6, 2017
PHP: Array support class and functions
View Arr.php
<?php
/**
* Support class for working with arrays.
*/
class Arr
{
/**
* Extend an associative array.
*
@bmoredrew
bmoredrew / jquery-boilerplate.js
Created Aug 30, 2017 — forked from tommcfarlin/jquery-boilerplate.js
[WordPress] Properly loading jQuery within WordPress without having to use the `noConflict` method, or creating your own reference such as `$wp = jQuery`.
View jquery-boilerplate.js
/**
* This gist demonstrates how to properly load jQuery within the context of WordPress-targeted JavaScript so that you don't
* have to worry about using things such as `noConflict` or creating your own reference to the jQuery function.
*
* @version 1.0
*/
(function( $ ) {
"use strict";
$(function() {
@bmoredrew
bmoredrew / rand-acf-repeater.php
Created Jun 9, 2017
Randomly display 3 ACF repeater rows
View rand-acf-repeater.php
<?php
$blocks = get_field('menu_blocks');
if( $blocks ) $count = 0;
{
shuffle( $blocks );
foreach( $blocks as $block )
{