Skip to content

Instantly share code, notes, and snippets.

View brianpurkiss's full-sized avatar

Brian Purkiss brianpurkiss

View GitHub Profile
@brianpurkiss
brianpurkiss / acf-img.php
Created April 3, 2019 15:13
Get correct size of ACF Image
<?php $image = get_field('img');
if( !empty($image) ) :
$alt = $image['alt'];
$size = 'large';
$img_url = $image['sizes'][ $size ]; ?>
<img src="<?php echo $img_url; ?>" alt="<?php echo $alt; ?>" />
<?php endif; ?>
<?php // more info: https://www.advancedcustomfields.com/resources/image/ ?>
@brianpurkiss
brianpurkiss / remove_searchwp_related.php
Created February 4, 2019 19:22
Remove Search WP from the standard position so it can be added manually where you want
@brianpurkiss
brianpurkiss / remove_woocommerce_actions
Created January 31, 2019 23:23
Remove a WooCommerce Action
// Add the action
add_action('init','sample_remove_product_meta');
// Declare the function
function sample_remove_product_meta() {
remove_action('woocommerce_single_product_summary','woocommerce_template_single_meta',40);
}
// First item in remove_action is the hook
// Second item in remove_action is what was hooked
@brianpurkiss
brianpurkiss / gutenberg-sample-content.html
Last active January 20, 2023 05:04 — forked from mailenkno/gutenberg-sample-content.html
WordPress Gutenberg Sample Content
<!-- wp:heading {"level":1} -->
<h1>This is a heading (H1)</h1>
<!-- /wp:heading -->
<!-- wp:heading -->
<h2>This is a heading (H2)</h2>
<!-- /wp:heading -->
<!-- wp:heading {"level":3} -->
<h3>This is a heading (H3)</h3>
@brianpurkiss
brianpurkiss / google-fonts.php
Created December 27, 2018 19:33
Adding Google Fonts to WordPress functions
<?php
//
// Add and optimize Google Fonts
//
// Add Google Fonts
// Enqueue google api webfont
function mod_fonts_enqueue() {
@brianpurkiss
brianpurkiss / favicon.php
Created December 27, 2018 19:03
Adding a favicon to WordPress through functions
<?php
// Setup favicon call
function add_favicon() {
$favicon_url = get_stylesheet_directory_uri() . '/library/images/favicon.png';
echo '<link rel="shortcut icon" href="' . $favicon_url . '" />';
}
// Adds favicon to WP Frontend and WP Dashboard
@brianpurkiss
brianpurkiss / bs_wp_pagination.php
Created August 9, 2018 13:43
Plugin free numbered pagination for WordPress, uses Bootstrap styles
function numbered_pagination($pages = '', $range = 2) {
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
@brianpurkiss
brianpurkiss / Gravity Forms + Bootstrap 4
Last active April 7, 2022 13:21 — forked from kirandash/Gravity Forms + Bootstrap
Helpful function for adding Bootstrap 4 classes to Gravity Forms fields.
<?php
/**
* Gravity Forms Bootstrap Styles
*
* Applies bootstrap classes to various common field types.
* Requires Bootstrap to be in use by the theme.
*
* Using this function allows use of Gravity Forms default CSS
* in conjuction with Bootstrap (benefit for fields types such as Address).
*
@brianpurkiss
brianpurkiss / shortcode.php
Created October 11, 2017 16:01
Bootstrap 4 Card WordPress Shortcode
<?php
function bootstrap_card( $atts, $content = null ) {
extract( shortcode_atts( array(
'width' => '300px',
'img' => '',
'title' => '',
'alt' => ''
), $atts )
);
@brianpurkiss
brianpurkiss / sample-sass-gulpfule.js
Created July 6, 2016 16:27
This gulp file's primary purpose is SASS compiling. It includes an auto compressor, prefixer, and watcher.
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
// primary gulp build
gulp.task('sass', function () {