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 / woocommerce-product-link-shortcode-stock.php
Last active August 8, 2019 16:28
WooCommerce | Create a shortcode for WooCommerce product links, which adds a class based on the if the product is out of stock or in stock.
@Garconis
Garconis / woocommerce-email-featured-products.php
Last active August 30, 2017 22:12
WooCommerce | Add Featured Products to bottom of certain WooCommerce emails
@Garconis
Garconis / divi-logo-swap.js
Last active June 4, 2018 10:54
Divi | Swap/change the Divi header logo on fixed header (After Scroll)
(function($) {
$(window).on('scroll', function() {
if(jQuery('#main-header').hasClass("et-fixed-header")) {
jQuery('#logo').attr('src','/wp-content/uploads/logo-alt.png');
}
else {
jQuery('#logo').attr('src','/wp-content/uploads/logo.png');
}
});
})( jQuery );
@Garconis
Garconis / add-taxonomy-to-page.php
Last active September 13, 2017 17:50
WordPress | Add a custom "category-style" taxonomy to Pages
<?php
/**
* Add custom Local taxonomies
* This basically lets you create Categories for Pages (similar to what you can do for Posts)
*
* Additional custom taxonomies can be defined here
* http://codex.wordpress.org/Function_Reference/register_taxonomy
*/
function fs_add_local_page_taxonomies() {
@Garconis
Garconis / shortcode-to-list-pages-of-taxonomy.php
Last active August 31, 2017 21:08
WordPress | Create a shortcode that lists pages of a custom taxonomy
<?php
/* Usage:
[fs-local-type type="wordpress"]
You can add additional parameters to the shortcode to override settings
Note: "local-type" is the name of the Taxonomy, and "wordpress" is the name of one of the terms
*/
// create shortcode to list all Local Types
add_shortcode( 'fs-local-type', 'fs_local_type_shortcode' );
@Garconis
Garconis / search-results-alphabetical.php
Created September 13, 2017 17:47
WordPress | Force search results to be in alphabetical order
<?php
function abc_search( $query ) {
if( $query->is_search && !is_admin() ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
}
add_filter( 'pre_get_posts','abc_search' );
@Garconis
Garconis / default-taxonomy-term-for-cpt.php
Last active September 14, 2017 12:32 — forked from mayeenulislam/Default Taxonomy Term for CPT
WordPress | Make Default taxonomy term(s) for Custom Post Type
<?php
/**
* Add an automatic default custom taxonomy for custom post type.
* If no taxonomy term is selected during post creation, the custom post will be assigned the specififed taxonomy terms during save.
* Just change the 'your-cpt-type' to your custom post type name
* and change 'fruit_tags' and 'soda_flavors' to the taxonomy slug(s) you want to target
* and change 'apple' and 'banana' and 'cola' with the slug(s) of the term(s) you want to make default
* you can add multiple taxonomy at once so the 'soda_flavors' line is applicable only then
*/
@Garconis
Garconis / divi-viewport-pinch-to-zoom.php
Created September 25, 2017 15:05
Divi | Add pinch and zoom (user scalable) to mobile viewport meta
<?php
// Removes et_add_viewport_meta from the wp_head phase
function remove_divi_actions() {
remove_action( 'wp_head', 'et_add_viewport_meta' );
}
// Call 'remove_divi_actions' during WP initialization
add_action('init','remove_divi_actions');
// add ability to pinch and zoom
@Garconis
Garconis / woocommerce-cart-count-shortcode.php
Created September 27, 2017 16:32
WooCommerce | Create shortcode to display WooCommerce cart quantity and total cost — working with Ajax
<?php
// Add Shortcode [cart_count]
function get_cart_count() {
//Check if WooCommerce is active
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
global $woocommerce;
$cart_url = $woocommerce->cart->get_cart_url();
$shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );
$cart_contents_count = $woocommerce->cart->cart_contents_count;
@Garconis
Garconis / divi-update-font-weights.php
Created September 27, 2017 17:19
Divi | Add more font weights to existing Google Font options
<?php
// add more font weights
add_filter('et_builder_google_fonts', 'my_custom_google_fonts', 10);
function my_custom_google_fonts($google_fonts) {
$google_fonts['Montserrat']['styles'] = '300,300i,400,400i,600,600i,700,700i';
return $google_fonts;
}