Skip to content

Instantly share code, notes, and snippets.

@jameskoster
jameskoster / functions.php
Last active February 9, 2017 23:56
Projects - Change number of project columns on archives
add_filter( 'projects_loop_columns', 'jk_projects_columns', 99 );
function jk_projects_columns( $cols ) {
$cols = 3;
return $cols;
}
@BronsonQuick
BronsonQuick / sennza_testimonials.php
Created March 9, 2014 06:00
Displaying CMB data example for JohnLion
<?php function sz_get_testimonials( $page_id ){
$testimonials = get_post_meta( $page_id, 'testimonial', false );
if ( $testimonials ) {
$testimonial_list = "\n<ul>\n";
foreach ( $testimonials as $testimonial ) {
$testimonial_image = false;
$testimonial_content = false;
$testimonial_list .= "\t<li class='row'>";
if ( $testimonial['testimonial-image'] ) {
$testimonial_image = wp_get_attachment_image( $testimonial['testimonial-image'], 'full', '', array( 'class' => 'columns small-3' ) );
@davidpaulsson
davidpaulsson / wp-get_id_by_slug
Created February 26, 2014 06:20
WordPress: Get page ID from slug
// Usage:
// get_id_by_slug('any-page-slug');
function get_id_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else {
return null;
}
@woogist
woogist / custom.css
Created February 3, 2014 12:32
styles for hiding and showing the secondary mobile menu in the right places
@media only screen and (min-width: 768px) {
/* Desktop styles go below this line */
#secondary-menu-container{
display: block !important;
}
#secondary-menu-container-mobile{
display: none !important;
}
}
@woogist
woogist / function.sphp
Created February 3, 2014 12:29
register another versions of the secondary menu in canvas under the mobile nevigation area.
add_action( 'woo_nav_inside', 'woo_custom_add_secondary_menu_to_mobile_nav', 10 );
function woo_custom_add_secondary_menu_to_mobile_nav () {
$menu_location = 'secondary-menu'; // Change this to be whichever menu location you want to add.
if ( has_nav_menu( $menu_location ) ) {
echo '<div id="' . $menu_location . '-container-mobile" class="col-full custom-menu-location">' . " ";
echo '<h3 class="secondary-menu">Secondary Menu</h3>';
@GaryJones
GaryJones / readme.md
Last active July 14, 2019 20:46
Custom Featured Post Widget plugin: Skeleton for amending the output of the Genesis Featured Post widget.
@spivurno
spivurno / gist:6584835
Created September 16, 2013 18:51
Gravity Forms Cookies // Saves the query string parameters from a users visit to a cookie and allows these values to be populated via Gravity Forms' Dynamic
<?php
/**
Plugin Name: Gravity Forms Cookies
Plugin URI: http://ounceoftalent.com/
Description: Saves the query string parameters from a users visit to a cookie and allows these values to be populated via Gravity Forms' Dynamic Population feature.
Version: 1.5
Author: David Smith
Author URI: http://ounceoftalent.com
License: GPL2
*/
@coenjacobs
coenjacobs / wc-custom-product-order.php
Created June 18, 2013 09:32
Adds a custom way of ordering products, in this example it's 'random' product ordering. This can also be set to be used as default via the Catalog tab in WooCommerce settings.
<?php
add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' );
function custom_woocommerce_get_catalog_ordering_args( $args ) {
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
if ( 'random_list' == $orderby_value ) {
$args['orderby'] = 'rand';
$args['order'] = '';
@BronsonQuick
BronsonQuick / gravity_forms_australian_formatted_address.php
Created May 13, 2013 01:57
Adds an Australian formatted Address dropdown to the Address field in Gravity Forms
function g8_aus_address( $address_types, $form_id ){
$address_types["australia"] = array(
"label" => "Australian",
"country" => "Australia",
"zip_label" => "Postcode",
"state_label" => "State",
"states" => array(
"NT" => "NT",
"ACT" => "ACT",
"NSW" => "NSW",
@jjeaton
jjeaton / functions.php
Created May 5, 2013 20:06
Remove current_page_parent class from Blog menu item when using custom post types and add class for the post type menu item. Hardcodes the menu-item title for each.
<?php
add_filter( 'nav_menu_css_class', 'je_portfolio_menu_item_classes', 10, 2 );
/**
* Add css classes to Portfolio CPT menu item, remove from Blog item
*
* Enables menu classes for CPTs.
* Pretty fragile, as it depends on the item titles for each menu item, change as required
*
* @param array $classes CSS classes for the menu item