Skip to content

Instantly share code, notes, and snippets.

View Frithir's full-sized avatar

Alex F Frithir

View GitHub Profile
@Frithir
Frithir / gist:ac43662a9d7204bfe28d
Created June 24, 2015 07:32
Add Current Cat to single template
<?php
if (!is_page() && !is_home()){
$catsy = get_the_category();
$myCat = $catsy[0]->cat_ID;
}
wp_list_categories('orderby=id&title_li=&current_category='.$myCat);
?>
@Frithir
Frithir / gist:cd109c4b4dd2c0c39e05
Created June 25, 2015 23:44
Wordpress Add drop dwon for custom tax
// Add drop dwon for custom tax
function restrict_books_by_genre() {
global $typenow;
$post_type = 'resource'; // change HERE
$taxonomy = 'resource_cats'; // change HERE
if ($typenow == $post_type) {
$selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : '';
$info_taxonomy = get_taxonomy($taxonomy);
wp_dropdown_categories(array(
'show_option_all' => __("Show All {$info_taxonomy->label}"),
@Frithir
Frithir / gist:871f2a397c1479bdae43
Created June 25, 2015 23:46
Wordpress Custom post type results template.
// Custom post type results template.
function template_chooser($template) {
global $wp_query;
$post_type = get_query_var('post_type');
if( isset($_GET['s']) && $post_type == 'directory_list' ) {
return locate_template('archive-directory.php'); // redirect to archive-search.php
}
if( isset($_GET['s']) && $post_type == 'resource' ) {
return locate_template('archive-resources.php'); // redirect to archive-search.php
}
@Frithir
Frithir / gist:457369d6012b2654cf21
Created June 26, 2015 05:55
CSS - This is the code responsible for the centering of content
/* This is the code responsible for the centering of content */
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-pack:center;
-webkit-justify-content:center;
-moz-justify-content:center;
@Frithir
Frithir / gist:8878639fb4cb092c4839
Created July 13, 2015 01:15
Woocommerce - Add cart number
<?php if (sizeof(WC()->cart->get_cart()) != 0): ?>
<?php global $woocommerce; echo $woocommerce->cart->cart_contents_count; ?>
<a href="<?php echo get_permalink(5); ?>">
<i class="fa fa-shopping-cart"></i> <?php global $woocommerce; echo $woocommerce->cart->cart_contents_count; ?> Cart
</a>
<?php endif ?>
@Frithir
Frithir / gist:599eaff9dc9854e4709a
Last active August 29, 2015 14:24
CSS - Select form element
select,
.woocommerce form .form-row select,
.gform_wrapper ul.gform_fields li.gfield div.ginput_complex span.ginput_left select,
.gform_wrapper ul.gform_fields li.gfield div.ginput_complex span.ginput_right select,
.gform_wrapper ul.gform_fields li.gfield input[type=radio],
.gform_wrapper ul.gform_fields li.gfield select {
-webkit-appearance: button;
-webkit-border-radius: 2px;
-webkit-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1);
-webkit-padding-end: 20px;
@Frithir
Frithir / gist:c85692523e64cc8904c5
Created September 30, 2015 01:02
Date picker remove dates and weekends
var holidays= ["2014-7-30","2015-07-29","2013-03-16"]
$('input').datepicker({
beforeShowDay: function(date){
var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
var noWeekend = $.datepicker.noWeekends(date);
if (noWeekend[0]) {
return [$.inArray(string, holidays) == -1];
}
else
@Frithir
Frithir / StyledImage.js
Created October 9, 2017 23:41
React Unsplashed random image loop
import React from 'react'
import styled from 'styled-components'
const StyledImage = styled.img`
filter: grayscale(100%);
width: 100px;
height: 100px;
`
export default ({count = 10}) => {
@Frithir
Frithir / gist:18d67e9dd927d54a9c1bd2697b884abf
Created October 17, 2017 04:34 — forked from kloon/gist:4541017
WooCommerce Clear Cart via URL
// check for clear-cart get param to clear the cart, append ?clear-cart to any site url to trigger this
add_action( 'init', 'woocommerce_clear_cart_url' );
function woocommerce_clear_cart_url() {
if ( isset( $_GET['clear-cart'] ) ) {
global $woocommerce;
$woocommerce->cart->empty_cart();
}
}
@Frithir
Frithir / custom-search-acf-wordpress.php
Created July 18, 2018 00:49 — forked from charleslouis/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
}