Hide WooCommerce Product Categories on Shop Page or other Page
You can hide certain WooCommerce product categories from the shop page or other targetted pages, by using an action called woocommerce_product_query Add it in your theme via functions.php and it works like so… So the action is wrapped in a conditional statement that targets the pages you want the Product Categories to not display. Then…
Read MoreInstalling WordPress wp-cli on macOS
Installing wp-cli on macOS – WordPress has a command line tool which operates similar to what Drush does for Drupal, it is called wp-cli and runs on macOS/Linux operating systems with a minimum of PHP 5.3.2 or later and WordPress 3.5.2 or later. Install wp-cli on macOS curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar Verify Install neilg@[~]: php wp-cli.phar –info PHP binary: /usr/bin/php PHP…
Read MoreAdd Taxonomy Terms as CSS Classes to a Post
You can use the body_class filter in WordPress to add the Taxonomy Terms of a Custom Taxonomy as CSS classes to a post. The CSS class appears in the body element and is only used if the post has been assigned to the taxonomy. The code goes in your functions.php file. add_filter( ‘body_class’, ‘themeprefix_add_taxonomy_class’…
Read MoreChange the WordPress Post Type name to Something Else
You can change the default Post type name in WordPress from Posts to something else like News using the get_post_type_object, normal behaviour of the Posts occur, just the label name in the WordPress dashboard has been changed. add_action( ‘init’, ‘cp_change_post_object’ ); // Change dashboard Posts to News function cp_change_post_object() { $get_post_type = get_post_type_object(‘post’); $labels =…
Read MoreCreate Shortcode for the Permalink in WordPress
You can create a shortcode for the permalink in WordPress to use in a string output or more likely as a value for a link attribute, this can be handy if you can’t use PHP in a certain interface. add_shortcode( ‘my_permalink’, ‘my_permalink’ ); // The Permalink Shortcode function my_permalink() { ob_start(); the_permalink(); return ob_get_clean(); }…
Read MoreAdd Search Icon After Menu using Beaver Themer with the Beaver Theme
Here’s how you can add a search icon after a menu in a header done in the Beaver Theme using Beaver Themer. Create a Shortcode for the Beaver Builder Search function add_shortcode( ‘bb_search’,’bb_search_shortcode’ ); /* Add Search via shortcode */ function bb_search_shortcode() { ob_start(); FLTheme::nav_search(); return ob_get_clean(); } Create the Header in Beaver Themer Create…
Read MoreAdd and Show Featured Images in Taxonomy Templates and in Single and Archive Posts
You can add a featured image to a Category Taxonomy in WordPress by using ACF and selecting the categories taxonomy, so now a new image field appears in the category back end page, the same process can be applied to other taxonomy templates such as custom taxonomies. Create a ACF Image Field for Taxonomy …
Read MoreShow All Post Meta Keys and Values for a Post in WordPress
If you wanted to see all the post meta keys and values for a post,page or custom post type in WordPress you can either see them in the database in the wp_postmeta table or you could use the get_post_meta function to retrieve all the post meta or a specific key. To output the data to…
Read MoreDon’t Output Empty Rows and HTML Mark Up in Beaver Builder
When you are using ACF field connections or insertions in Beaver Builder with Beaver Themer if the field is not populated the HTML mark up is still rendered on the page, even though the field is blank some of its HTML markup will have valid CSS applied to it and affect the spacing on the…
Read MoreAdd Link to the Count in WooCommerce Product Category Menu
The WooCommerce product category menu can be manipulated by making a copy of the walker class it is defined in and editing it. The WC_Product_Cat_List_walker class lives in wooc0mmerce/includes/walkers/class-product-cat-list-walker.php, you can make a copy of this and include it in your child theme and include it. Best to create a classes subfolder in your child…
Read More