Skip to content

Instantly share code, notes, and snippets.

View jacobwise's full-sized avatar

Jacob Wise jacobwise

View GitHub Profile
@jacobwise
jacobwise / Time since last custom post type
Last active August 29, 2015 14:14
Using c.bavota and from the WordPress Codex for human_time_diff() these function return a readable time since last post for custom post types
/**
* Display time since post was published
*
* @uses human_time_diff() Return time difference in easy to read format
* @uses get_the_time() Get the time the post was published
* @uses current_time() Get the current time
*
* @return string Timestamp since post was published
*
* @author c.bavota
// Debouncer
(function($,sr){
// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {
var obj = this, args = arguments;
@jacobwise
jacobwise / Advanced Custom Fields and JSON API
Last active November 1, 2017 13:11
How to add Advance Custom Fields to the JSON API in WordPress.
<?php
add_filter('json_api_encode', 'json_api_encode_acf');
function json_api_encode_acf($response)
{
if (isset($response['posts'])) {
foreach ($response['posts'] as $post) {
json_api_add_acf($post); // Add specs to each post
}
@jacobwise
jacobwise / Recent Posts Widget Extended SCSS
Created July 18, 2014 20:09
A way to use Recent Posts Widget Extended in your website project using SCSS to modify the look.
.rpwe-block {
ul {
list-style: none !important;
margin-left: 0 !important;
padding-left: 0 !important;
}
li {
border-bottom: 1px solid #eee;
margin-bottom: 10px;
@jacobwise
jacobwise / Remove Category Description
Created July 14, 2014 18:36
jQuery required to remove the description for WordPress admin.
(function($) {
$('#tag-description').closest('.form-field').remove();
$('#description').closest('.form-field').remove();
})(jQuery);
@jacobwise
jacobwise / Adding JavaScript to WordPress Admin Screen
Last active August 29, 2015 14:03
Shows how to add a separate JavaScript file for the admin screen section of your WordPress Website
<?php
function jw_admin_scripts() {
wp_enqueue_script( 'adminscripts', get_stylesheet_directory_uri() . '/assets/js/admin.min.js', array('jquery'), NULL, true );
}
add_action( 'admin_enqueue_scripts', 'jw_admin_scripts' );
@jacobwise
jacobwise / Remove Category Description Field
Last active May 6, 2021 19:26
How to remove the category description column
/**
* Remove default description column from category
*
*/
function jw_remove_taxonomy_description($columns)
{
// only edit the columns on the current taxonomy, replace category with your custom taxonomy (don't forget to change in the filter as well)
if ( !isset($_GET['taxonomy']) || $_GET['taxonomy'] != 'category' )
return $columns;
@jacobwise
jacobwise / Re-Position-Yoast-SEO-plugin-metabox
Last active June 5, 2018 16:39
Re-position Yoast SEO plugin to high priority. Just change high to low to put it at the bottom.
/**
*
* Filter Yoast SEO Metabox Priority
* @author Jacob Wise
* @link http://swellfire.com/code/filter-yoast-seo-metabox-priority
*
*/
add_filter( 'wpseo_metabox_prio', 'jw_filter_yoast_seo_metabox' );
function jw_filter_yoast_seo_metabox() {
return 'high';
@jacobwise
jacobwise / Recent Custom Posts
Last active June 1, 2020 22:57
Recent posts for a Custom Post Type
<?php
/**
* Recent Custom Posts
* @author Jacob Wise
* @link http://swellfire.com/code/recent-custom-posts
*
* @param string $post_type
* @param int $numberposts
* @echo string $output
@jacobwise
jacobwise / Genesis Custom Sidebar
Last active April 2, 2018 03:35
Switch Genesis Primary sidebar for a custom sidebar
<?php
//* Remove Primary Sidebar if blog, single, or CPT
add_action( 'get_header', 'jw_remove_primary_sidebar' );
function jw_remove_primary_sidebar() {
if ( is_singular( 'post' ) || is_home() || is_singular( 'code' ) || is_singular( 'tutorial' ) || is_archive() ) {
/** Remove default sidebar */
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );