Skip to content

Instantly share code, notes, and snippets.

@amielucha
amielucha / WordPress - sort archive by name.php
Last active August 29, 2015 14:16
Sort posts archive by name.
function sort_archive_by_name( $query ) {
/*
* Change the 'if' condition to the taxonomy/category you want to apply the new sorting
*/
if ( is_tax('product-category') ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
}
add_action( 'pre_get_posts', 'sort_archive_by_name' );
@amielucha
amielucha / wp-oembed-filter.php
Last active July 12, 2017 22:30
WordPress oEmbed filters
// usage on page:
// echo wp_oembed_get('https://www.youtube.com/watch?v=123qweasd', array('width'=>458, 'autoplay'=>0, 'rel'=>0, 'showinfo'=>0 ));
// add parameters to oembed
add_filter('oembed_result','lc_oembed_result', 10, 3);
function lc_oembed_result($html, $url, $args) {
// $args includes custom argument
$newargs = $args;
@amielucha
amielucha / WooCommerce - products per page.php
Last active August 29, 2015 14:21
WooCommerce - edit the amount of products per page
// Display 24 products per page
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 24;' ), 20 );
@amielucha
amielucha / wc_remove_actions.php
Last active August 29, 2015 14:21
WooCommerce - remove actions
// will not work in functions.php, use in plugins only
function woo_changes(){
//remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
//add_action( 'woocommerce_checkout_after_customer_details', 'woocommerce_order_review', 10 );
}
add_action('plugins_loaded','woo_changes');
// Removes the 'Project Category:' or 'Category:' part in archive's h1
add_filter( 'get_the_archive_title', function ($title) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '<span class="vcard">' . get_the_author() . '</span>' ;
} elseif ( is_tax() ) {
$title = single_term_title( '', false );
@amielucha
amielucha / wp-toolset-layouts-loop.php
Created June 19, 2015 16:19
Toolset Layouts theme integration
<?php
/*
* Use the Toolset Layouts loop if it's active.
* Usage: Replace the standard loop in the template file
*/
if ( function_exists('the_ddlayout') ) {
// Toolset Layouts
the_ddlayout();
} else {
// Standard WP loop
@amielucha
amielucha / wp-types-disable-content-template.php
Created July 9, 2015 11:41
WP-Types: disable content template
// WP-Types: disable content template
function types_remove_template_selector() {
remove_meta_box( 'views_template', 'post', 'side' );
remove_meta_box( 'views_template', 'page', 'side' );
}
add_action( 'admin_head', 'types_remove_template_selector', 20);
@amielucha
amielucha / social-icons-stack.html
Last active May 11, 2016 10:45
Font Awesome social icons stack
<!-- fa class - square -->
<div class="social">
<a target="_blank" href="#" class="fa-stack fa-lg">
<i class="fa fa-stop fa-stack-2x fa-stack-3x"></i>
<i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
</a>
<a target="_blank" href="#" class="fa-stack fa-lg">
<i class="fa fa-stop fa-stack-2x fa-stack-3x"></i>
<i class="fa fa-linkedin fa-stack-1x fa-inverse"></i>
</a>
@amielucha
amielucha / jquery-svg-replacer.js
Created September 8, 2015 11:20
jQuery replace svg file with inline svg
/*
* Replace all SVG images with inline SVG
*/
jQuery('img.svg').each(function(){
var $img = jQuery(this);
var imgID = $img.attr('id');
var imgClass = $img.attr('class');
var imgURL = $img.attr('src');
jQuery.get(imgURL, function(data) {
@amielucha
amielucha / blockquote-quotes-wrap.less
Last active September 11, 2015 10:17
Blockquote - add quotes
.blockquote {
p {
&:before {
content: '\201C'; // “
}
&:after {
content: '\201D'; // ”
}
}