//shortcode for mini-cart function jma_woo_minicart($atts){ ob_start(); global $woocommerce; echo ‘<a class=”cart-contents” href=”‘ . ‘ $woocommerce->cart->get_cart_url()’ . ‘” title=”View your shopping cart”>’; echo sprintf(_n(‘%d item’, ‘%d items’, $woocommerce->cart->cart_contents_count, ‘woothemes’), $woocommerce->cart->cart_contents_count) . ‘ – ‘ . $woocommerce->cart->get_cart_total() . ‘</a>’; $x = ob_get_contents(); ob_end_clean(); return $x; } add_shortcode(‘jma_woo_minicart’,’jma_woo_minicart’); // Ensure cart contents update when products are added to […]
For more code ideas go to my GitHub gists:
https://gist.github.com/johnnya23
Query Revision (pre_get_posts)
function jma_add_custom_taxonomy_query( $query ) { if( $query->is_admin || !$query->is_main_query() || true == $query->query_vars[‘suppress_filters’] ) return; //order cats by title (use ‘name’ for slug) if( $query->is_category(array(148,160,161)) ) { $query->set(‘orderby’, ‘title’); $query->set(‘order’, ‘ASC’); } } add_action( ‘pre_get_posts’, ‘jma_add_custom_taxonomy_query’ );
No Frills Pdf Button
function pdf_button_filter( $content ) { $pre_content = $post_content = ‘<a class=”pdf-button btn” href=”javascript:pdf_url=location.href;location.href=\’http://pdfmyurl.com?s=l&url=\’+escape(pdf_url)”>A pdf button!</a>’; $content = $pre_content . $content . $post_content; return $content; } function add_pdf_button_content(){//whatever template condition you want here //if(is_single())//for just posts //if(is_page())//for just pages if(is_singular( ‘park’ ))// park is the custom post type add_filter(‘the_content’, ‘pdf_button_filter’, 1); } add_action(‘template_redirect’, ‘add_pdf_button_content’);
ACF on Taxonomy Page
use get_queried_object to grab the value of the taxonomy (here in the location taxonomy). function country_content_addition() { $queried_object = get_queried_object(); $country_input = get_field(‘camp’, $queried_object); $camp_input = get_field(‘camp_description’, $queried_object); do whatever ….. } function add_tab_content(){ if(is_tax(‘location’)) add_action(‘themeblvd_content_top’, ‘country_content_addition’); } add_action(‘template_redirect’, ‘add_tab_content’);
Add Repeating Custom Field to Custom Post Type with Content Filter
function park_content_filter( $content ) { $new_content = ‘<div class=”camp-wrap clearfix”>’; $new_content .= ‘<div class=”item-title”>Camp</div>’; $new_content .= ‘<div class=”item-value”>Description</div>’; if(function_exists(‘get_field’) && get_field(‘camp’)){// camp is the field group while(has_sub_field(‘camp’)){ $new_content .= ‘<div class=”item-title”>’ . get_sub_field(‘camp_name’) . ‘</div>’; $new_content .= ‘<div class=”item-value”>’ . get_sub_field(‘camp_description’) . ‘</div>’; } } $new_content .= ‘</div><!–camp-wrap–>’; $content = $content . $new_content; return $content; […]
Woo Testimonials Quote Styling
Add this to functions.php to enable psuedo elements: function jma_child_scripts() { wp_add_inline_script(‘fontawesome’, ‘window.FontAwesomeConfig={searchPseudoElements:true}’, ‘before’); } add_action(‘wp_enqueue_scripts’, ‘jma_child_scripts’); The CSS: .quote { margin-bottom: 20px; } .quote blockquote { font: 14px/20px italic Arial, Helvetica, sans-serif; padding: 8px; margin: 5px; text-indent: 40px; border-color: rgba(253, 186, 49, 0.5); position: relative; } .quote blockquote::before, .quote blockquote::after { font-family: “Font Awesome […]
Accordion Sidebar Menu
Shows all the children under the current root item and all other root items. function jma_sidebar_addon() { global $post; $ancestors = get_ancestors( $post->ID, ‘page’ ); $ancestor_id = array_pop($ancestors); $ancestor_id = $ancestor_id? $ancestor_id: $post->ID; $root_pages = get_pages(array(‘parent’ => 0)); echo ‘<ul>’; foreach ($root_pages as $root_page) { $jma_classes = ”; $show_kids = false; $has_kids = false; if( […]
Slider Shadow
For Themeblxd Nivo Slider: .home #tb-slider-home:before { content: “”; display: block; position: absolute; bottom: -28px; left: 0; width: 100%; height: 28px; background: url(‘../images/shadow.png’) no-repeat; background-size: 100%; } The Image:
Clearfix
In the event we are dealing with some situation where it is not convenient to add the clearfix class (which is available frequently including in JumpStart), we can add the styling to the div that needs clearfix. So if we had markup like: <div class=”wrapping-div-that-i-cant-change”> <div style=”float: left; width: 45%”> Lorem ipsum dolor sit amet, […]