Skip to content

Instantly share code, notes, and snippets.

View JiveDig's full-sized avatar

Mike Hemberger JiveDig

View GitHub Profile
@JiveDig
JiveDig / mai-adjacent-post-nav-by-category.php
Last active July 27, 2017 18:59
Add adjacent post navigation to posts in a specific category, by ID.
<?php
// Remove adjacent post nav.
add_action( 'after_setup_theme', function(){
remove_post_type_support( 'post', 'genesis-adjacent-entry-nav' );
});
/**
* Add adjacent post navigation to posts
* in a specific category, by ID.
@JiveDig
JiveDig / recursive-term-metadata.php
Created July 21, 2017 14:05
Get the specified metadata value for the term or from one of it's parent terms.
<?php
/**
* Get the specified metadata value for the term or from
* one of it's parent terms.
*
* @param WP_Term $term Term object
* @param string $key The meta key to retrieve.
* @param bool $check_enabled Whether to check if custom archive settings are enabled.
*
@JiveDig
JiveDig / functions.php
Created June 19, 2017 17:01
Ignore WooCommerce Membership product restrictions when facets are used on Shop page.
<?php
/**
* Ignore WooCommerce Membership product restrictions when facets are used on Shop page.
*
* @uses FacetWP
* @uses WooCommerce Memberships
*/
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
if ( 'wc_user_membership' == $query->get( 'post_type' ) ) {
@JiveDig
JiveDig / genesis_author_box_shortcode.php
Last active May 15, 2019 14:49
WordPress shortcode to Genesis author boxes by role or user ID(s)
/**
* Shortcode to get author box(es) by user IDs or roles.
* Originally taken from genesis_author_box()
*
* [author_box] will display the author box of the current post author.
* [author_box users="12,4,20"] will display author boxes of users 12, 4, and 20.
* [author_box users="12,4,20"] will display author boxes of users 12, 4, and 20.
* [author_box roles="author"] will display author boxes of all authors.
* [author_box roles="author, editor"] will display author boxes of all authors and contributors.
* [author_box roles="author, editor" exclude="24"] will display author boxes of all authors and contributors, excluding user 24.
@JiveDig
JiveDig / restful-p2p-connection-button.php
Last active May 31, 2021 23:34
Example usage of helper function to display a Restful P2P connection button. Uses https://github.com/JiveDig/restful-p2p/
<?php
$args = array(
'name' => 'users_to_pages', // name of the P2P connection
'from' => get_current_user_id(), // ID of the P2P 'from' object
'to' => get_the_ID(), // ID of the P2P 'to' object
'connect' => 'Connect', // Text to create a connection
'connected' => 'Connected!', // Text when a connection is already made
'loading' => 'Loading...', // Text to display while connection is being made
);
@JiveDig
JiveDig / restful-p2p-connection-button.php
Created August 27, 2016 23:16
Display a Restful P2P connection button
<?php
$args = array(
'name' => 'users_to_pages', // name of the P2P connection
'from' => get_current_user_id(), // ID of the P2P 'from' object
'to' => get_the_ID(), // ID of the P2P 'to' object
'connect' => 'Connect', // Text to create a connection
'connected' => 'Connected!', // Text when a connection is already made
'loading' => 'Loading...', // Text to display while connection is being made
);
@JiveDig
JiveDig / remove-tinymce-editor-buttons.php
Last active February 24, 2023 06:00
Remove buttons/items from the WordPress TinyMCE editor
<?php
/**
* Removes buttons from the first row of the tiny mce editor
*
* @link http://thestizmedia.com/remove-buttons-items-wordpress-tinymce-editor/
*
* @param array $buttons The default array of buttons
* @return array The updated array of buttons that exludes some items
*/
add_filter( 'mce_buttons', 'jivedig_remove_tiny_mce_buttons_from_editor');
@JiveDig
JiveDig / acf-pricing-table.css
Last active February 8, 2021 17:18
ACF Pro json file to create a pricing table field group
/* Pricing Table
--------------------------------------------- */
.pricing-table {
box-sizing: border-box;
display: -webkit-flex;display: -ms-flexbox;display: flex;
-webkit-flex: 0 1 auto;-ms-flex: 0 1 auto;flex: 0 1 auto;
-webkit-flex-wrap: wrap;-ms-flex-wrap: wrap;flex-wrap: wrap;
-webkit-flex-direction: row;-ms-flex-direction: row;flex-direction: row;
-webkit-justify-content: space-between;-ms-flex-pack: justify;justify-content: space-between;
@JiveDig
JiveDig / wp-edit-post-front-end.php
Last active September 16, 2020 19:14
Filter WP 'Edit Post' link to go to front end /edit-post/ page with ?post_id=123 query arg to allow editing posts via the front end
<?php
/**
* Filter WP 'Edit Post' link to go to front end /edit-post/ page
*
* @author Mike Hemberger
* @link http://thestizmedia.com/front-end-post-editing-with-caldera-forms/
* @return string url to front end for with query arg source post ID ( ?post_id=123 )
*/
add_filter( 'get_edit_post_link', 'tsm_edit_post_link', 10, 1 );
@JiveDig
JiveDig / edit-post-link-query-arg.php
Last active September 16, 2020 19:13
Add a custom 'Edit Post' link on posts the logged in user authored.Uses tsm_is_current_users_post( $post_id ) helper function here https://gist.github.com/JiveDig/c2d59c4efd996c41dd23. Adds ?post_id=123 query arg to the end of a page URL
<?php
/**
* Add a custom 'Edit Post' link on posts the logged in user authored
* Links to a separate page with ?post_id=123 query string
* Uses tsm_is_current_users_post( $post_id ) helper function
*
* @author Mike Hemberger
* @link http://thestizmedia.com/front-end-post-editing-with-caldera-forms/
* @return bool/string false or edit post link