WordPress Plugin Error – Notice: Trying to get property of non-object in…

I’m getting this error in relation to the ‘Grid & List toggle for Woocommerce’ plugin, specifically this file: /wp-content/plugins/grid-list-toggle-for-woocommerce/woocommerce_grid_list.php on line 115   Basically, the error was corrected by surrounding the code after global $post with the following statement: if ( is_object( $post )) {   Click here for the corrected file.

Display Product Categories with Thumbnail Image

Use shortcode: [show-product-categories-with-image] Add the following to your functions.php file. function showProductCat() { $cat_args = array( ‘orderby’ => ‘name’, ‘order’ => ‘asc’, ‘hide_empty’ => true, ); $product_categories = get_terms( ‘product_cat’, $cat_args ); $result = “<div class=’product-categories-with-image’>”; if( !empty($product_categories) ){ foreach ($product_categories as $key => $category) { $thumb_id = get_woocommerce_term_meta( $category->term_id, ‘thumbnail_id’, true ); $term_img = wp_get_attachment_image_src( $thumb_id, ‘thumbnail’, true ); $cat_img = “”; if ($term_img[3]) { $cat_img = “<img src=’”.

Redirect for a Specific Page on WordPress

Here’s a snippet of code to redirect users who land on a specific page of your wordpress site. You will need the page id. Add it to your functions.php file. The code below redirect users to my site. 🙂 function redirect_to_another_page() { $page_id_to_redirect = 119; //enter page id here $destination = ‘’; //enter destination url here if ( is_page($page_id_to_redirect) ) { wp_redirect( $destination, 301 ); exit; } } add_action( ‘template_redirect’,

Deactive a Sidebar or Widgetized Area

Here’s how to deactive a Sidebar or Widgetized Area in WordPress so it won’t show on the website and neither will it show on the Widgets section of the wordpress backend. First, get the name of the sidebar, you may need to check the theme functions file to get exactly it is. In this case, we will assume that the sidebar name is ‘sidebar-1’. Add the code below to your

Embed a Visual Composer page with CSS Styles

Here’s how to embed a page created with Visual Composer onto another page with the page CSS styles included. You can add this code to either the header or footer file of your theme, or another theme file for that matter. First step: note the id of the page to be embedded. Use this snippet and put the id into the first line of code as indicated below. <?php $id

Load / Enqueue the latest version of css and javascript files

Add the following code to your functions.php file to load / enqueue the most recent child theme style.css file or any css/javascript file. $cache_buster = date(“YmdHi”); function my_custom_files() { wp_register_style( ‘childstyle’, get_stylesheet_directory_uri() . ‘/style.css’, $cache_buster, ‘all’ ); wp_enqueue_script( ‘my-scripts’, get_stylesheet_directory_uri() . ‘/scripts.js’, array(), $cache_buster, true ); wp_enqueue_style( ‘childstyle’ ); } add_action( ‘wp_enqueue_scripts’, ‘my_custom_files’, 11);

Get Contents from Visual Composer Page and Load into Another with CSS Styling

<?php $id = 200; //page id $shortcodes_custom_css = get_post_meta( $id, ‘_wpb_shortcodes_custom_css’, true ); if ( ! empty( $shortcodes_custom_css ) ) { echo ‘<style type=”text/css” data-type=”vc_shortcodes-custom-css-‘.$id.’”>’; echo $shortcodes_custom_css; echo ‘</style>’; } $post = get_post($id); echo apply_filters(‘the_content’, $post->post_content); ?>

Send E-mail with Attachment using PHP

Here’s a perfectly working snippet of PHP code which will send an e-mail with an attachment (of any file type). This code has been updated to disable jumbled/garbage/corruption which showed up on gmail (while it was fine on Outlook). //File settings $fileatt = “../uploads/myLovelyFile.pdf; $fileatttype = “application/octet-stream”; //Octet-stream is a file type to allow all types of files $fileattname = “myLovelyFile”; //Read file contents $file = fopen($fileatt, ‘rb’); $data =

Add a new widget area to a WordPress theme

If you are familiar with WordPress themes then you know that a lot of themes have a widgetized sidebar. This means that you can add, remove, and re-order widgets on your WordPress website by using the “widget” section of your WordPress dashboard. Having a widgetized sidebar is very useful, but you may want to widgetize other parts of your WordPress theme as well. This is very easy to do, and