0 1 2 3 4 5 6 7 |
function jma_child_post_meta($setup) { $setup['config']['screen'][] = 'personnel'; return $setup; } add_filter('themeblvd_post_meta', 'jma_child_post_meta'); |
Title Filtering
What ever you do is going to end up within the h1 tag, but this will keep it out of the menu etc.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
function personnel_filter($x) { $value = get_field('position'); $x = '<div class="person-sub">' . $value . '</div><!--person-sub-->' . $x; return $x; } function jma_person_title_cond($query) { global $wp_query; if ($query === $wp_query) { add_filter('the_title', 'personnel_filter', 10, 2); } else { remove_filter('the_title', 'personnel_filter', 10, 2); } } function jma_child_redirect() { if (is_singular('personnel') && get_field('position')) { add_action('loop_start', 'jma_person_title_cond'); } } add_action('template_redirect', 'jma_child_redirect'); |
Page by Page Sidebars
Using Advanced Custom Fields Create WYSIWYG Fields “Right Sidebar” (id right_sidebar) and/or “Left Sidebar” (id left_sidebar).
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
function jma_custom_sidebar($side){ $content = get_field( $side.'_sidebar'); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); echo $content . '<div style="clear: both; margin-bottom: 20px"></div>'; } /** * Call our sidebar functions based on the * current position and current sidebar layout. */ function jma_custom_sidebars( $position ) { // Get current sidebar layout $layout = themeblvd_config( 'sidebar_layout' ); if( $position == 'left' ) { // Display any sidebars to be located on the LEFT // based on the current sidebar layout. // Display the left sidebar if( $layout == 'sidebar_left' || $layout == 'double_sidebar' || $layout == 'double_sidebar_left' ) { do_action( 'themeblvd_fixed_sidebar_before', 'left' ); if(get_field('left_sidebar')) jma_custom_sidebar('left'); else themeblvd_display_sidebar( 'sidebar_'.$position ); do_action( 'themeblvd_fixed_sidebar_after' ); } // Display the right sidebar if there is a // double sidebar over on the left. if( $layout == 'double_sidebar_left' ) { do_action( 'themeblvd_fixed_sidebar_before', 'right' ); if(get_field('right_sidebar')) jma_custom_sidebar('right'); else themeblvd_display_sidebar( 'sidebar_right' ); do_action( 'themeblvd_fixed_sidebar_after' ); } } else if( $position == 'right' ) { // Display any sidebars to be located on the RIGHT // based on the current sidebar layout. // Display the left sidebar if there is a // double sidebar over on the right. if( $layout == 'double_sidebar_right' ) { do_action( 'themeblvd_fixed_sidebar_before', 'left' ); if(get_field('left_sidebar')) jma_custom_sidebar('left'); else themeblvd_display_sidebar( 'sidebar_left' ); do_action( 'themeblvd_fixed_sidebar_after' ); } // Display the right sidebar if( $layout == 'sidebar_right' || $layout == 'double_sidebar' || $layout == 'double_sidebar_right' ) { do_action( 'themeblvd_fixed_sidebar_before', 'right' ); if(get_field('right_sidebar')) jma_custom_sidebar('right'); else themeblvd_display_sidebar( 'sidebar_'.$position ); do_action( 'themeblvd_fixed_sidebar_after' ); } } } function jma_template_redirect(){ if(is_page() && function_exists('get_field') && (get_field('right_sidebar') || get_field('left_sidebar'))){ remove_action( 'themeblvd_sidebars', 'themeblvd_fixed_sidebars' ); add_action( 'themeblvd_sidebars', 'jma_custom_sidebars' ); } } add_action('template_redirect', 'jma_template_redirect'); |
WooCommerce Filters
Remove related products
0 1 2 3 4 5 |
function jma_remove_related_products( $args ) { return array(); } add_filter('woocommerce_related_products_args','jma_remove_related_products', 10); |
Redirect ‘add to cart’ button
0 1 2 3 4 5 6 7 |
function jma_redirect_add_to_cart() { global $woocommerce; $checkout_url = $woocommerce->cart->get_checkout_url();//get_cart_url(); for cart return $checkout_url; } add_filter ('add_to_cart_redirect', 'jma_redirect_add_to_cart'); |
Redirect ‘back to shop’ button
0 1 2 3 4 5 |
function jma_return_to_shop_redirect() { return get_permalink(682); } add_filter( 'woocommerce_return_to_shop_redirect', 'jma_return_to_shop_redirect' ); |
Turn off Themeblvd Woo Images (re-enable woo image size options)
0 1 2 |
add_filter('themeblvd_woocommerce_images', '__return_false'); |
Add content to customer emails
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
Function jma_email_before_order_table($order, $sent_to_admin){ $items = $order->get_items(); foreach($items as $item){ $jma_item_list[] = $item['item_meta']['_product_id'][0];//create an array lising item ids in this woocommerce order } if(array_intersect(get_pro_cat_ids('minisites'), $jma_item_list)){/* 21,199 is minisite purchase 80*/ ?> <div style="padding: 10px; border: solid 1px #cc0200; margin-bottom: 15px"> <h3 style="margin: 0!important">Click the button below to access your MiniSite Construction Form Instructions</h3> <span style="font-size:10px">(disregard if you have already completed this form)</span><br/> <a style="display: inline-block; padding: 5px 10px; margin: 5px auto; color: #ffffff; background: #005389; text-decoration: none; font-weight:bold" href="<?php echo get_permalink(169) ?>"><?php echo get_the_title( 169 ); ?></a> </div> <?php } if(in_array(101, $jma_item_list)){/* 101 dns help addon purchase*/ ?> <div style="padding: 10px; border: solid 1px #cc0200; margin-bottom: 15px"> <h3 style="margin: 0!important">Click the button below to access your DNS Help Form</h3> <span style="font-size:10px">(disregard if you have already completed this form)</span><br/> <a style="display: inline-block; padding: 5px 10px; margin: 5px auto; color: #ffffff; background: #005389; text-decoration: none; font-weight:bold" href="<?php echo get_permalink(88) ?>"><?php echo get_the_title( 88 ); ?></a> </div> <?php } if(in_array(99, $jma_item_list)){/* 99 header design addon purchase*/ ?> <div style="padding: 10px; border: solid 1px #cc0200; margin-bottom: 15px"> <h3 style="margin: 0!important">Click the button below to access your Header Design Form</h3> <span style="font-size:10px">(disregard if you have already completed this form)</span><br/> <a style="display: inline-block; padding: 5px 10px; margin: 5px auto; color: #ffffff; background: #005389; text-decoration: none; font-weight:bold" href="<?php echo get_permalink(170) ?>"><?php echo get_the_title( 170 ); ?></a> </div> <?php } if(in_array(97, $jma_item_list)){/* 97 newsletter popup addon purchase*/ ?> <div style="padding: 10px; border: solid 1px #cc0200; margin-bottom: 15px"> <h3 style="margin: 0!important">Click the button below to access your Popup Newsletter Form</h3> <span style="font-size:10px">(disregard if you have already completed this form)</span><br/> <a style="display: inline-block; padding: 5px 10px; margin: 5px auto; color: #ffffff; background: #005389; text-decoration: none; font-weight:bold" href="<?php echo get_permalink(171) ?>"><?php echo get_the_title( 171 ); ?></a> </div> <?php } ?> <?php } add_action('woocommerce_email_before_order_table', 'jma_email_before_order_table', 10, 2); |
helper for above function
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
/* helper - * function get_pro_cat_ids * returns an array of ids for products in category $catslug * @param string $catslug slug of the category in question * * return array of product id (or false of failure) * * */ function get_pro_cat_ids($catslug){ $args = array( 'post_type' => 'product', 'product_cat' => $catslug, 'posts_per_page' => -1, ); $minisites = get_posts( $args ); if(count($minisites)){ foreach($minisites as $minisite){ $return[] = $minisite->ID; } }else{ $return[] = 'empty'; } return $return; } |
Remove/edit tabs (user new callback to edit tab content)
0 1 2 3 4 5 6 7 8 9 10 11 12 |
function jma_remove_woo_product_tabs( $tabs ) { echo '<pre>'; print_r($tabs);echo '</pre>'; unset( $tabs['description'] ); // Remove the description tab unset( $tabs['reviews'] ); // Remove the reviews tab unset( $tabs['additional_information'] ); // Remove the additional information tab return $tabs; } function jma_manage_woo_content(){ add_filter( 'woocommerce_product_tabs', 'jma_remove_woo_product_tabs', 98 ); } add_action('template_redirect', 'jma_manage_woo_content'); |
print_r on $tabs array
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Array ( [description] => Array ( [title] => Description [priority] => 10 [callback] => woocommerce_product_description_tab ) [reviews] => Array ( [title] => Reviews (1) [priority] => 30 [callback] => comments_template ) ) |
Hide Empty […]
Solve HTTP Error in Media Library
Add to functions.php
0 1 2 3 4 5 |
function change_graphic_lib($array) { return array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); } add_filter( 'wp_image_editors', 'change_graphic_lib' ); |
Portfolio Filtering
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
function jma_portfolio_item_cpt_labels($labels){ $labels = array( 'name' => __( 'Members', 'portfolios' ), 'singular_name' => __( 'Member', 'portfolios' ), 'add_new' => __( 'Add New Member', 'portfolios' ), 'edit_item' => __( 'Edit Member', 'portfolios' ), 'new_item' => __( 'New Member', 'portfolios' ), 'all_items' => __( 'Members', 'portfolios' ), 'view_item' => __( 'View Members', 'portfolios' ), 'search_items' => __( 'Search Members', 'portfolios' ), 'not_found' => __( 'No members found', 'portfolios' ), 'menu_name' => __( 'Members' ) ); return $labels; } add_filter('themeblvd_portfolio_item_cpt_labels', 'jma_portfolio_item_cpt_labels'); function jma_portfolio_item_cpt_args($args){ $args['rewrite'] = array( 'slug' => 'members' ); return $args; } add_filter('themeblvd_portfolio_item_cpt_args', 'jma_portfolio_item_cpt_args'); function jma_portfolio_tax_labels($labels){ // Add "Portfolio" taxonomy (i.e. Items are grouped into portfolios) $labels = array( 'name' => __( 'Business Categories', 'portfolios' ), 'singular_name' => __( 'Business Category', 'portfolios' ), 'search_items' => __( 'Search Business Categories', 'portfolios' ), 'all_items' => __( 'All Business Categories', 'portfolios' ), 'parent_item' => __( 'Parent Business Category', 'portfolios' ), 'parent_item_colon' => __( 'Parent Business Category:', 'portfolios' ), 'edit_item' => __( 'Edit Business Category', 'portfolios' ), 'update_item' => __( 'Update Business Category', 'portfolios' ), 'add_new_item' => __( 'Add New Business Category', 'portfolios' ), 'new_item_name' => __( 'New Business Category Name', 'portfolios' ), 'menu_name' => __( 'Business Categories', 'portfolios' ) ); return $labels; } add_filter('themeblvd_portfolio_tax_labels', 'jma_portfolio_tax_labels'); function jma_portfolio_tax_args($args){ $args['rewrite'] = array( 'slug' => 'business-cat' ); return $args; } add_filter('themeblvd_portfolio_tax_args', 'jma_portfolio_tax_args'); function jma_portfolio_tag_tax_labels($labels){ // Add "Portfolio Tag" taxonomy $labels = array( 'name' => __( 'Business Types', 'portfolios' ), 'singular_name' => __( 'Business Type', 'portfolios' ), 'search_items' => __( 'Search Business Types', 'portfolios' ), 'all_items' => __( 'All Business Types', 'portfolios' ), 'edit_item' => __( 'Edit Business Type', 'portfolios' ), 'update_item' => __( 'Update Business Type', 'portfolios' ), 'add_new_item' => __( 'Add New Business Type', 'portfolios' ), 'new_item_name' => __( 'New Business Type Name', 'portfolios' ), 'menu_name' => __( 'Business Types', 'portfolios' ) ); return $labels; } add_filter('themeblvd_portfolio_tag_tax_labels', 'jma_portfolio_tag_tax_labels'); function jma_portfolio_tag_tax_args($args){ $args['rewrite'] = array( 'slug' => 'business-type' ); return $args; } add_filter('themeblvd_portfolio_tag_tax_args', 'jma_portfolio_tag_tax_args'); |
Display Standard Post Date
0 1 2 3 4 5 6 7 8 |
function jma_blog_meta_args( $args ) { $args['time'] = 'standard'; return $args; } add_filter('themeblvd_blog_meta_args', 'jma_blog_meta_args'); add_filter('themeblvd_search_meta_args', 'jma_blog_meta_args'); add_filter('themeblvd_mini_list_meta_args', 'jma_blog_meta_args'); |
Button Filtering
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
function jma_frontend_locals( $args ) { $args['read_more'] = 'Read more >> '; return $args; } add_filter( 'themeblvd_frontend_locals', 'jma_frontend_locals' ); function jma_get_button_class( $class ) { $class = 'inline-btn'; return $class; } function jma_template_redirect() { if(is_page(10)) add_filter( 'themeblvd_get_button_class', 'jma_get_button_class' ); } add_action( 'template_redirect', 'jma_template_redirect' ); |
Push and Pull FIltering in ThemeBlvd
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
function jma_sidebar_layouts( $layouts ){ $layouts['double_sidebar_left']['columns'] = array( 'content' => 'col-sm-2 col-sm-jmapush-10', 'left' => 'col-sm-8 ', 'right' => 'col-sm-2 col-sm-jmapull-10' ); $layouts['sidebar_left']['columns'] = array( 'content' => 'col-sm-10', 'left' => 'col-sm-2 ', ); return $layouts; } add_filter( 'themeblvd_sidebar_layouts', 'jma_sidebar_layouts' ); function jma_remove_pull($class){ if( 'portfolio_item' == get_post_type() ){ $class = str_replace(array('-pull-', '-push-'), '', $class); $class = str_replace(array('jma'), '', $class); } return $class; } add_filter( 'themeblvd_column_class', 'jma_remove_pull' ); |
Edit Default Portfolio Link Behavior
This filter is in framework > admin > meta > meta.php. for themeblvd_post_meta about line 430. for themeblvd_page_meta about line 97. Notice the condition refers just to the portfolio_item post type:
0 1 2 3 4 5 6 7 8 9 10 |
function jma_post_filter($setup) { $setup['options']['tb_thumb_link']['std'] = 'post';//link from say the grid to the post or use 'thumbnail' to show enlarged lightbox version (the default value is 'inactive') $setup['options']['tb_thumb_link_single']['std'] = 'thumbnail';//link the single page featured image to enlarged lightbox or 'yes' or 'no' to apply grid value to single post if($_GET['post_type'] == 'portfolio_item' || get_post_type($_GET['post']) == 'portfolio_item')//just for the portfolio post type $setup['options']['tb_thumb']['std'] = 'hide';//hide the featured image on the single post other options are 'full' and 'default' (the default value is set in theme options) return $setup; //to change the image size on a single post change the content.php (copy to child theme) themeblvd_the_post_thumbnail('your_image_size'); } add_filter('themeblvd_post_meta', 'jma_post_filter'); |