Skip to content

Instantly share code, notes, and snippets.

View Garconis's full-sized avatar
🐞
Debugging

Jon Fuller Garconis

🐞
Debugging
View GitHub Profile
@Garconis
Garconis / acf-states.txt
Created August 10, 2018 16:21 — forked from michaeldozark/acf-states.txt
State list for Advanced Custom Fields select field
AL : Alabama
AK : Alaska
AZ : Arizona
AR : Arkansas
CA : California
CO : Colorado
CT : Connecticut
DE : Delaware
DC : District of Columbia
FL : Florida
@Garconis
Garconis / inject-cpt-post-every-X-posts.php
Created August 23, 2018 17:55
WordPress | Inject a new custom post type posting into the loop every X amount of regular posts
<?php
add_action( 'wp', 'fs_only_do_on_homepage' );
function fs_only_do_on_homepage() {
if( is_front_page() ) {
/* change the query to inject ads after every X frequency */
// https://www.gowp.com/blog/inserting-custom-posts-loop/
add_filter( 'the_posts', 'fs_insert_ads', 10, 2 );
@Garconis
Garconis / acf-post-loop-based-on-meta-and-taxonomy.php
Created September 5, 2018 18:17
WordPress | Loop for displaying only certain posts with certain ACF content and taxonomy
<?php
// create shortcode to list all addresses of a "Location" Page Type
add_shortcode( 'fs-location-address-loop', 'fs_sc_location_address_loop' );
function fs_sc_location_address_loop( $atts ) {
ob_start();
// define attributes and their defaults
extract( shortcode_atts( array (
'post_type' => 'page',
@Garconis
Garconis / exclude-cpt-from-search.php
Created September 20, 2018 14:11
WordPress | Exclude certain Custom Post Types from search
<?php
// include only certain post types in the search results
function gc_filter_search($query) {
if (!$query->is_admin && $query->is_search) {
$query->set('post_type', array('post', 'page', 'book'));
}
return $query;
}
add_filter('pre_get_posts', 'gc_filter_search');
@Garconis
Garconis / highlight-link-if-section-in-viewport.js
Last active March 29, 2022 10:38
WordPress | Highlight Nav Menu Item if ID is in Viewport
@Garconis
Garconis / divi-show-section-based-on-clicked-link-id.js
Last active March 4, 2019 15:44
Divi | Show a section that has an ID when the link with that ID is clicked (and hide the others) — good for creating faux tabs and tab content
@Garconis
Garconis / woocommerce-products-per-page-plugin-with-divi.php
Created October 10, 2018 19:37
WooCommerce Products Per Page + Divi
<?php
// help make the plugin of WooCommerce Products Per Page work with the Divi Theme
add_action( 'pre_get_posts', 'fs_custom_posts_per_page', 30 );
function fs_custom_posts_per_page( $query = false ) {
if ( is_admin() ) return;
if ( ! is_a( $query, 'WP_Query' ) || ! $query->is_main_query() ) return;
if ( $query->is_category ) {
$query->set( 'posts_per_page', apply_filters( 'loop_shop_per_page', 9 ) );
@Garconis
Garconis / wpdatatables-content-manipulation.js
Created October 23, 2018 20:45
WordPress | wpDataTables column data overrides
// Code for inventory image
function inventoryTable(){
// grab the URL in the new column and make into an image
jQuery('td.inventory-col-photo a').each(function () {
var image_anchor = jQuery(this).find("a");
var image_url = jQuery(this).attr("href");
//jQuery(this).prepend(jQuery('<img>',{class:'theImg',src:'theImg.png'}))
jQuery(this).html('<img src="' + image_url + '">');
});
// grab text in the Stock # column and assume its OK to make into a clickable image with that filename
@Garconis
Garconis / progress-maps-trigger-search-form-and-wrap-links.js
Last active December 7, 2018 18:03
Progress Maps | Trigger the search form box if a button is clicked, and also wrap URLs with a link
@Garconis
Garconis / tml-change-lost-password-page-if-on-certain-url.php
Created March 4, 2019 15:16
Theme My Login | Shortcodes to spit out a custom Logout anchor and Helpers to force-change the Lost Password URL for certain pages/forms.
<?php
/* shortcode that will output the Logout URL with Kiosk URL redirect, as anchor and text */
// [fs_kiosk_logout_url_anchor class="whatever-it-is you-want"]Log Out[/fs_kiosk_logout_url_anchor]
add_shortcode( 'fs_kiosk_logout_url_anchor', 'fs_sc_kiosk_logout_url_anchor' );
function fs_sc_kiosk_logout_url_anchor( $atts, $content = null ) {
// define attributes and their defaults
$a = shortcode_atts( array(
'class' => 'kiosk-logout-url-anchor'
), $atts );