Skip to content

Instantly share code, notes, and snippets.

K. M. Walsh kmwalsh

Block or report user

Report or block kmwalsh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
kmwalsh / migrate-acf-sel-to-tax.php
Last active Dec 7, 2018
Migrate ACF select values into taxonomy, then apply taxonomy terms to all posts
View migrate-acf-sel-to-tax.php
* Ran into an issue with a WP site where I needed to change an ACF select dropdown into a real WordPress taxonomy. Wrote this to move the data from an ACF select to taxonomy. This will create terms from an ACF select (manually, have to get the data from the ACF field editing interface). Then it will go through all posts and apply the new taxonomy term according to the ACF select value that already exists on the post.
* ⚠⚠⚠ WARNING ⚠⚠⚠
* This is not a professional migration thing. If you use this:
* Put into `functions.php` or as your own `mu-plugin` file.
* Run on a local installation first. If you can run locally and export your DB back to live, even better.
* No idea how it'd perform if you had thousands of ACF fields. It worked OK for me with 250 potential ACF select values.
kmwalsh / wordpress--breadcrumb-navxt--search-and-filter
Created Nov 16, 2018
Manually fix Breadcrumb NavXT breadcrumbs for pages on Search & Filter pages
View wordpress--breadcrumb-navxt--search-and-filter
* Fix Breadcrumb NavXT breadcrumbs for pages on Search & Filter pages
add_action('bcn_after_fill', 'kmw_navxt_filter_breadcrumb_fix');
function kmw_navxt_filter_breadcrumb_fix($trail)
$query_var = get_query_var( 'sfid' );
if( !empty( $query_var ) ) {
kmwalsh / gist:92d4d681c822a855ef2caa059ce3e117
Created May 22, 2018
Enqueuing WordPress scripts - all pages, just posts, just certain templates
View gist:92d4d681c822a855ef2caa059ce3e117
function 8ii010b_scripts() {
// this adds your script to all pages on the site
wp_enqueue_script( 'custom-8ii010-js', get_template_directory_uri() . '/js/YOUR-JS-FILE.js', array(), '20151215', true );
// this adds your script to all single posts
if ( is_singular('post') ) {
wp_enqueue_script( 'custom-8ii010-js', get_template_directory_uri() . '/js/YOUR-JS-FILE.js', array(), '20151215', true );
kmwalsh / gist:b02acf86d05ccd1767ea9fc4c261bff5
Created May 22, 2018
Redirect single post to external link - WordPress
View gist:b02acf86d05ccd1767ea9fc4c261bff5
* =============================================================
* Redirect single post to external link
* =============================================================
// this checks to make sure that the function doesn't already exist
// if something else in your WP uses a function named redirect_cpt_to_external_link
// this check to see whether it exists or not will keep your site from crashing
if ( ! function_exists('redirect_cpt_to_external_link') ) {
kmwalsh / gist:abebb8d8a9d42e41f0ad893267d27008
Last active Jan 24, 2017
modify wordpress menu for anchor links in semi-single page site
View gist:abebb8d8a9d42e41f0ad893267d27008
* modify primary menu so that the anchor links always point back to the homepage
if( ! function_exists('nav_items') ) {
add_filter( 'wp_get_nav_menu_items','nav_items', 11, 3 );
function nav_items( $items, $menu, $args )
if( is_admin() )
return $items;
You can’t perform that action at this time.