Skip to content

Instantly share code, notes, and snippets.

View kevinwhoffman's full-sized avatar

Kevin W. Hoffman kevinwhoffman

View GitHub Profile
@kevinwhoffman
kevinwhoffman / loop-csswizardry-grids.php
Last active August 29, 2015 14:07
WordPress - Loop within csswizardry-grids
<div class="grid">
<!--
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
--><div class="grid__item">
<!-- do stuff -->
@kevinwhoffman
kevinwhoffman / loop-custom.php
Last active April 8, 2022 11:22
WordPress - Custom Post Type Loop
<?php
$loop = new WP_Query( array(
'post_type' => 'Property',
'posts_per_page' => -1
)
);
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
@kevinwhoffman
kevinwhoffman / template.php
Created November 11, 2014 03:56
WordPress - Page Template Header
<?php
/* Template Name: Template Name */
?>
@kevinwhoffman
kevinwhoffman / functions.php
Last active August 29, 2015 14:10
WordPress - functions.php Boilerplate
<?php
// Remove unnecessary menu items from admin menu
function remove_menus () {
if( is_admin() ) {
global $menu;
$restricted = array(
// __('Posts'),
// __('Comments')
);
@kevinwhoffman
kevinwhoffman / zip-pricing.php
Last active August 29, 2015 14:25
Checking price based on zip code
$zip = '00001'; // $zip can be populated by form submission
$pricing = $array(
// zip => price associated with that zip
'00001' => 10,
'00002' => 15,
'00003' => 20
);
// check if zip exists within array, and return the matching price
@kevinwhoffman
kevinwhoffman / dequeue-styles.php
Last active October 6, 2015 18:17
Dequeue Styles
<?php
// Code used by plugin to enqueue styles
wp_enqueue_style('wpProQuiz_front_style', plugins_url('css/wpProQuiz_front'.(WPPROQUIZ_DEV ? '' : '.min').'.css', WPPROQUIZ_FILE), array(), WPPROQUIZ_VERSION );
wp_enqueue_style( 'sfwd_front_css', plugins_url( 'assets/css/front.css', dirname( __FILE__ ) ) );
wp_enqueue_style( 'sfwd_template_css', get_stylesheet_directory_uri().'/learndash/learndash_template_style.css' );
// My attempt at dequeuing styles
add_action( 'wp_print_styles', 'vms_dequeue_styles', 100 );
@kevinwhoffman
kevinwhoffman / wp-user-query.php
Last active October 19, 2015 02:33
WP_User_Query with Serialized Array
<?php
// Return users with a single language (English)
$args = array(
'meta_key' => 'wpcf-language-skill',
'meta_value' => 'English'
'meta_compare' => 'LIKE'
);
@kevinwhoffman
kevinwhoffman / wp-login-redirect.php
Last active October 22, 2015 08:54
WP Redirect Users After Login
<?php
/**
* Redirect users after login
*/
add_filter('login_redirect', 'vms_login_redirect', 10, 3);
function vms_login_redirect( $redirect_to, $request, $user ) {
if( !isset( $_REQUEST['redirect_to'] ) ) {
if ( current_user_can( 'manage_options' ) ) { // does not return true even for admins
return admin_url();
/*
- I have a CPT named Galleries and within this CPT there are 6 individual galleries, all using the same format.
- I have used the Enhanced Media Library plugin to allow a category(ies) to be added each image uploaded.
- single-galleries.php - is a template used for displaying each of these individual galleries.
- Each individual gallery has aprox 4 categories in use that are assigned to the different images.
- There are aprox 24 categories for all of the images across the 6 individual galleries(1-2 per image)
Problem: code for "gallery-filter" below is currently echoing out ALL(~24) media categores.
Solution needed: for only those categories acutally used on the page (rememeber 6 diff galleries)
@kevinwhoffman
kevinwhoffman / plugin.php
Last active April 15, 2022 20:46 — forked from mathetos/plugin.php
Dependent Plugin Activation/Deactivation and Alert
<?php
/*
* Dependent Plugin Activation/Deactivation
*
* Sources:
* 1. https://pippinsplugins.com/checking-dependent-plugin-active/
* 2. http://10up.com/blog/2012/wordpress-plug-in-self-deactivation/
*
*/