Remove related products function jma_remove_related_products( $args ) { return array(); } add_filter(‘woocommerce_related_products_args’,’jma_remove_related_products’, 10); Redirect ‘add to cart’ button 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 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 […]
Order by Expiration
Using the post expirator plugin see useful plugins function my_custom_posts_query( $query, $args ){ if( $args[‘query’] == ‘expires_first’ ){ $query = array( ‘cat’ => 1, ‘order’ => ‘ASC’, ‘meta_key’ => ‘_expiration-date’, ‘orderby’ => ‘meta_value’ ); if(is_front_page())//optional $query[‘posts_per_page’] = 5; } return $query; } add_filter( ‘themeblvd_posts_args’, ‘my_custom_posts_query’, 10, 2 ); For woo products with variable category query […]
Grid of Taxonomies
Some options to add a grid of taxonomy pages. The first doesn’t include pageing the second requires adding a second post type to hold the pages. // no pageing with this one function jma_series_grid ($atts){ ob_start(); extract( shortcode_atts( array( ), $atts ) ); $series_array = get_terms( ‘series’ ); foreach ($series_array as $series) {//get values from […]
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’ );
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; […]
Display List of Related Pages from Hierarchy in Sidebar
Linked pages related to the current page. If is root page shows itself as title with all children below. Else shows immediate parent as title with all pages at its level below (depth can be changed, with -1 showing all without hierarchy). function jma_sidebar_addon() { global $post; if($post->post_parent) { $children = wp_list_pages(‘title_li=&child_of=’.$post->post_parent.’&echo=0&depth=1′); }else{ $children = […]
Display Posts by Category [shortcode]
Suppose we want to display a list of post links in the sidebar that are in “child” categories of the “News” category (ie “Boating News” followed by its posts, “Fishing News” followed by its posts, in this case from the last 90 days because of the filter). We could include this code in functions.php: add_filter(‘widget_text’, […]
Sticky Posts in Category Pages
How do we get sticky posts to “stick” to category pages? The answer to this question turned out to be much more involved than I had imaged. After scouring the internet/codex I managed to found this solution. /* stickies to top for news category (34) */ function jma_child_sticky_posts_to_top($posts, $q) { //check to see if it’s […]