Skip to content

Instantly share code, notes, and snippets.

View JiveDig's full-sized avatar

Mike Hemberger JiveDig

View GitHub Profile
@JiveDig
JiveDig / README.md
Last active January 10, 2025 20:10
Custom WP-CLI commands to export/import specific posts via CLI.

Custom WP-CLI commands to export/import specific posts via CLI.

How to Export

Export posts of a specific type with all post data.

wp jivedig export_posts_to_csv --post_type=post --posts_per_page=10 --offset=0

Export pages of a specific type by post ID with all post data.

@JiveDig
JiveDig / class-woocommerce-product-taxonomy-import-export.php
Last active November 29, 2024 17:12
WooCommerce Product Taxonomy Import/Export. Makes it easy to add custom taxonomies to built in WooCommerce import/export feature.
<?php
// Prevent direct file access.
defined( 'ABSPATH' ) || die;
/**
* The main plugin class.
*
* @version 0.2.0
*
@JiveDig
JiveDig / class-msn-news.php
Created July 30, 2024 20:02
Custom WP feed for MSN News
<?php
// Prevent direct file access.
defined( 'ABSPATH' ) || die;
/**
* Add MSN News feed.
* Flush permalinks after adding this feed.
*
* @return void
@JiveDig
JiveDig / custom_taxonomy_term_list.php
Last active July 24, 2024 18:04
Show list of terms from a custom taxonomy linked to their archive pages
<?php
add_action( 'genesis_before_loop', 'spears_do_resource_term_links' );
function spears_do_resource_term_links() {
// Show Custom Taxonomy
$args = array( 'taxonomy' => 'resource_type' );
$terms = get_terms('resource_type', $args);
@JiveDig
JiveDig / show_post_terms.php
Created September 2, 2014 19:33
Show post terms with links - get_the_term_list
<?php
$language = wp_get_post_terms($post->ID, 'ft_language');
if( $language ) {
echo get_the_term_list( $post->ID, 'ft_language', '<li><span class="detail">Languages:</span>', ', ', '</li>' );
}
@JiveDig
JiveDig / acf_front_end_edit.php
Last active July 24, 2024 18:03
ACF front end post editing
<?php
/**
* Check if user is logged in and is post author
* Setup functions for front end post editing
* @author Mike Hemberger
* @link http://thestizmedia.com/front-end-post-editing-with-acf-pro/
* @uses Advanced Custom Fields Pro
* @uses Sidr
*/
@JiveDig
JiveDig / wp-edit-post-front-end.php
Last active July 24, 2024 18:03
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 / 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 / class-woocommerce-account-tab.php
Last active July 4, 2024 03:15
A PHP class to create new WooCommerce account tabs.
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Mai_WooCommerce_Account_Tab' ) ):
/**
* A class to create new WooCommerce account tabs.
*
* @version 0.1.0
@JiveDig
JiveDig / class-user-role-base.php
Last active May 30, 2024 14:06
A PHP class for WordPress that allows you to change the author base by user role.
<?php
// Prevent direct file access.
defined( 'ABSPATH' ) || die;
if ( ! class_exists( 'Mai_User_Role_Base' ) ):
/**
* The User Role Base class.
*
* @version 0.2.0