Skip to content

Instantly share code, notes, and snippets.

@danjjohnson
danjjohnson / gist:3553066
Created August 31, 2012 14:02
Editing fonts with CSS
.entry a:link, .entry a:visited {
font-family: Georgia, serif;
color: #0066cc;
font-weight: bold;
font-size: 1.1em;
}
@danjjohnson
danjjohnson / post-format-shortcode.php
Created September 13, 2012 10:39
Add Post Format shortcode for meta manager
if ( ! function_exists( 'woo_shortcode_post_format' ) ) {
function woo_shortcode_post_format () {
$format = get_post_format( $post->ID );
$output = sprintf('<span class="categories">%s</span> ', $format );
return apply_filters( 'woo_shortcode_post_format', $output, $atts );
// Add product categories to the "Product" breadcrumb in WooCommerce.
// Get breadcrumbs on product pages that read: Home > Shop > Product category > Product Name
add_filter( 'woo_breadcrumbs_trail', 'woo_custom_breadcrumbs_trail_add_product_categories', 20 );
function woo_custom_breadcrumbs_trail_add_product_categories ( $trail ) {
if ( ( get_post_type() == 'product' ) && is_singular() ) {
global $post;
$taxonomy = 'product_cat';
@danjjohnson
danjjohnson / gist:5713284
Last active December 18, 2015 02:48
On Topic theme - display header in sidebar layout on every page.
@media only screen and (min-width: 1024px) {
.page #header, .single-post #header, .single-product #header {
position: fixed;
left: 0;
top: 0;
width: 25%;
max-width: 500px;
height: 100%;
-webkit-transition: all ease-in-out 0.2s;
-moz-transition: all ease-in-out 0.2s;
@danjjohnson
danjjohnson / timeline.css
Created June 13, 2013 11:54
Change the colours in The One Pager timeline
/* Change timeline post background colours to #f0f0f0 and #eeeeee on hover */
#posts-timeline .timeline-post {background: #f0f0f0;}
#posts-timeline .timeline-post:nth-child(1n):before {border-color: #f0f0f0 transparent transparent transparent;}
#posts-timeline .timeline-post:hover {background: #eeeeee;}
#posts-timeline .timeline-post:nth-child(1n):hover:before {border-color: #eeeeee transparent transparent transparent;}
@media only screen and (min-width: 768px) {
#posts-timeline .timeline-post:nth-child(2n):before {border-color: transparent transparent #f0f0f0 transparent;}
#posts-timeline .timeline-post:nth-child(2n):hover:before {border-color: transparent transparent #eeeeee transparent;}
}
add_action( 'woo_post_inside_after', 'woo_customise_testimonials_archive' );
if ( ! function_exists( 'woo_customise_testimonials_archive' ) ) {
function woo_customise_testimonials_archive() {
if ( 'testimonial' == get_post_type() ) {
$author = get_the_title();
$info = get_post_custom();
echo '<cite class="author">' . $author . '<span class="excerpt">' . $info[_byline][0] . '</span><!--/.excerpt-->';
echo '<span class="url"><a href="' . $info[_url][0] . '">' . $info[_url][0] . '</a></span>';
}
@danjjohnson
danjjohnson / courses
Created February 13, 2014 11:08
Sensei: Change 'New Courses' to 'Available Courses'
add_filter('gettext', 'translate_text');
add_filter('ngettext', 'translate_text');
function translate_text($translated) {
$translated = str_ireplace('New Courses', 'Available Courses', $translated);
return $translated;
}
@danjjohnson
danjjohnson / superstore-product-limit.php
Last active August 29, 2015 14:01
Change the number of recent products displayed on Superstore homepage
<?php
add_action( 'admin_head', 'woo_custom_options', 50 );
function woo_custom_options(){
$limit = array();
//set the limit to 40
for ( $i = 1; $i <= 40; $i++ ) {
$limit[$i] = $i;
}
@danjjohnson
danjjohnson / module-archive-limit.php
Last active May 17, 2016 06:29
Sensei - Set number of lessons to show per page on a Module archive page
<?php
function module_archive_limit( $query ) {
if( is_tax( Sensei()->modules->taxonomy ) && $query->is_main_query() ) {
// Set number of lessons per page
$query->set( 'posts_per_page', 20 );
}
}
add_action( 'pre_get_posts', 'module_archive_limit', 15, 1 );
@danjjohnson
danjjohnson / gist:46a07c0f703ccfe3c465
Last active August 29, 2015 14:03
Sensei - Rename "New Courses" to "Recent Courses"
add_filter( 'sensei_new_courses_text', 'sensei_custom_new_courses_text', 10 );
function sensei_custom_new_courses_text () {
$text = "Recent Courses";
return $text;
}