The popular open-source contract for web professionals by Stuff & Nonsense
- Originally published: 23rd December 2008
- Revised date: March 15th 2016
- Original post
function defer_parsing_of_js($url) | |
{ | |
if (is_admin()) return $url; //don't break WP Admin | |
if (false === strpos($url, '.js')) return $url; | |
if (strpos($url, 'jquery.js')) return $url; | |
return str_replace(' src', ' defer src', $url); | |
} | |
add_filter('script_loader_tag', 'defer_parsing_of_js', 10); |
function repeater_tax_results($categories, $query) { | |
if ('kiujhhjkhjku' == $query->get('post_type')) { | |
$categories = array(); | |
$category_query = new WP_Term_Query(array( | |
'taxonomy' => 'category', // Change 'category' to the taxonomy you want to query. | |
'hide_empty' => false, | |
'exclude' => get_cat_ID('Uncategorized'), // Exclude the 'Uncategorized' category | |
)); |
function load_splide_scripts() { | |
wp_register_script('splide-js', 'https://cdn.jsdelivr.net/npm/@splidejs/[email protected]/dist/js/splide.min.js', array(), '4.1.4', true); | |
wp_register_style('splide-css', 'https://cdn.jsdelivr.net/npm/@splidejs/[email protected]/dist/css/splide.min.css', array(), '4.1.4'); | |
if (is_front_page()) { | |
wp_enqueue_script('splide-js'); | |
wp_enqueue_style('splide-css'); | |
} | |
} | |
add_action('wp_enqueue_scripts', 'load_splide_scripts'); |
/* Wrap product image with a box container. */ | |
add_action('prima_custom_scripts', 'prima_custom_product_image_box'); | |
function prima_custom_product_image_box() { | |
echo 'jQuery(document).ready(function($) {'; | |
echo '$(".woocommerce ul.products li.product a img, .woocommerce-page ul.products li.product a img").wrap("<div class=\'product-image-box\'></div>");'; | |
echo '$(".woocommerce ul.products li.product .onsale, .woocommerce-page ul.products li.product .onsale").each(function() { var item = $(this); item.prependTo(item.parent().find(".product-image-box")); });'; | |
echo '});'; | |
echo "\n"; | |
} |
<?php | |
/* | |
WordPress Template Hierarchy (as of WordPress 4.8) | |
is_404() -------------------------------------------------------------------------------------------------> 404.php | |
is_search() ----------------------------------------------------------------------------------------------> search.php | |
is_front_page() ------------------------------------------------------------------------------------------> front-page.php | |
is_home() ------------------------------------------------------------------------------------------------> home.php |
<?php | |
/** | |
* WordPress Query Comprehensive Reference | |
* Compiled by luetkemj - luetkemj.com | |
* | |
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters | |
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php | |
*/ | |
$args = array( |
<?php | |
/** | |
* Blog Intro | |
* | |
*/ | |
function be_blog_intro() { | |
$content = get_post( get_option( 'page_for_posts' ) )->post_content; | |
if( $content ) | |
echo '<div class="blog-intro">' . wpautop( $content ) . '</div>'; |
<?php | |
/** | |
* Plugin Name | |
* | |
* @package Custom_Featured_Post_Widget | |
* @author Gary Jones | |
* @license GPL-2.0+ | |
* @link http://gamajo.com/ | |
* @copyright 2013 Gary Jones, Gamajo Tech | |
*/ |
<?php | |
/** | |
* Archive Post Class | |
* @since 1.0.0 | |
* | |
* Breaks the posts into three columns | |
* @link http://www.billerickson.net/code/grid-loop-using-post-class | |
* | |
* @param array $classes |