Skip to content

Instantly share code, notes, and snippets.

View solid-pixel's full-sized avatar

Alessandro Benassi solid-pixel

View GitHub Profile
@solid-pixel
solid-pixel / git-deployment.md
Last active February 2, 2018 11:38 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your lokal GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, let's say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like my Deepl.io to act upon a Web-Hook that's triggered that service.

@solid-pixel
solid-pixel / functions.php
Created January 17, 2018 15:20
Add custom post types to submenu
<?php //remove this line
add_filter( 'wp_get_nav_menu_items', 'cpt_locations_filter', 10, 3 );
function cpt_locations_filter( $items, $menu, $args ) {
$child_items = array();
$menu_order = count($items);
$parent_item_id = 0;
foreach ( $items as $item ) {
@solid-pixel
solid-pixel / leverage.conf
Last active July 29, 2020 20:44
Leverage Browser Caching with NGINX
location ~* \.(?:css|js|txt)$ {
expires 1y;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
add_header Cache-Control "public";
}
#Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
@solid-pixel
solid-pixel / functions.php
Last active January 17, 2018 10:41
[WordPress] Use the plugin "The Grid" to display ACF relationships
<?php //remove this
function my_query_args($query_args, $grid_name) {
if ($grid_name == 'Related Treatments') {
$treatments = get_field('related_treatments', get_the_ID(), false);
$query_args['post__in'] = $treatments;
}
return $query_args;
}
@solid-pixel
solid-pixel / scripts.js
Created October 11, 2017 14:02
Re-render ACF Google Map on Click event
(function($) {
/*
* render_map
*
* This function will render a Google Map onto the selected jQuery element
*
* @type function
* @date 8/11/2013
* @since 4.3.0
@solid-pixel
solid-pixel / readme.md
Created August 27, 2017 21:25
Display Multiple Authors in Author Box

Requires Co-Authors Plus WordPress Plugin and ACF

@solid-pixel
solid-pixel / scripts.js
Created July 28, 2017 15:06
Detect ScrollWheel direction with jQuery
$('.article-body').on('wheel', function(e) {
var delta = e.originalEvent.deltaY;
if (delta > 0)
alert('down');
else
alert('up');
@solid-pixel
solid-pixel / single.php
Created July 24, 2017 13:44
Use ACF Galleries field with ACF Flexible Content
<?php
// GALLERY LAYOUTS - Flexible Content
// check if the flexible content field has rows of data
if( have_rows('galleries') ):
// loop through the rows of data
while ( have_rows('galleries') ) : the_row();
@solid-pixel
solid-pixel / functions.php
Last active May 3, 2017 14:50
Add Admin Column showing ACF Post Object's field
<?php // remove this tag
// ADD NEW COLUMN
function JOBDIVISION_columns_head($defaults) {
$defaults['division_post_obj'] = 'Division'; // Replace with your column name
return $defaults;
}
// SHOW THE TITLE
@solid-pixel
solid-pixel / page.php
Created March 21, 2017 13:06
Set ACF image (ID) as Background
<?php
$imgID = get_field('field_slug');
$imgSize = "large"; // (thumbnail, medium, large, full or custom size)
$imgArr = wp_get_attachment_image_src( $imgID, $imgSize );
// $url = $image[0];
// width = $image[1];
// height = $image[2];