Tips and Tricks

Filtering Referral Spam in Google Analytics

Referral spam can seriously mess with your data in Google Analytics. Using the filter function can block spammy domains and improve the accuracy of your stats. Edit the View for the website (Property) in question Create a New Filter Set Filter Type to Custom Set to Exclude Select filter field to Referral Create regex expression…

Read More

Enable or Disable Automatic Updates of WordPress Core, Themes and Updates using Functions.php

Placing this in functions.php will enable automatic updates of the WordPress core, plugins and themes. /* configure automatic updates */ add_filter( ‘auto_update_core’, ‘__return_true’ ); add_filter( ‘auto_update_plugin’, ‘__return_true’ ); add_filter( ‘auto_update_theme’, ‘__return_true’ ); Changing __return_true to __return_false disables said updates. These can be further refined to limit the level of updates and include only certain plugins.…

Read More

Child Themes Done the Right Way using functions.php

Was a time when linking a child theme to the parent theme was done via an import in the style sheet. No more, now the best way to do this is via the functions.php file as follows: function my_theme_enqueue_styles() { $parent_style = ‘parent-style’; wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’ ); wp_enqueue_style( ‘child-style’, get_stylesheet_directory_uri() . ‘/style.css’, array(…

Read More

Migrate Multiple Domains to New Domain Using .htaccess

Ok so you have multiple domains all pointing to your main domain where your site lives. But now you want to change the main domain, so you need to redirect all requests, for all the alias domains, to the new main domain and generate a 301 response so search engines and browsers know that the…

Read More

cPanel Email Error: "retry time not reached for any host after a long failure period"

This can be caused by a corrupt database file. Fix it by running the following SSH commands as root: cd /var/spool/exim/db rm -f retry retry.lockfile rm -f wait-remote_smtp wait-remote_smtp.lockfile service exim restart or /usr/sbin/exim_tidydb -t 1d /var/spool/exim retry > /dev/null /usr/sbin/exim_tidydb -t 1d /var/spool/exim reject > /dev/null /usr/sbin/exim_tidydb -t 1d /var/spool/exim wait-remote_smtp > /dev/null /scripts/courierup…

Read More

Simple Down for Maintenance Page using .htaccess

.htaccess To put a site into maintenance mode put either of the following in an .htaccess file in the site root. 1) Very simple #close the site down ############################################ RewriteEngine On ErrorDocument 403 /maintenance.php order deny,allow deny from all allow from xxx.xxx.xx.xxx #end of closed site rules################################## The “allow from” line permits access only from…

Read More

Display Posts Shortcode – Change Date Format

Default date format in the Display Posts Shortcode plugin is hard coded in the plugin but it can be changed using a filter. By default the date format is (8/29/15) which is useless for countries other than the USA. The following function can be placed in the THEME/functions.php file to change the format so that…

Read More

MYOB can't send email invoices

If MYOB fails to send and invoice by email and throws an I/O type error it might be because there is an Esales.pdf file already in the temp folder. To fix simply delete all Esale.pdf files from the temp folder: 1) Open the command line from the Start menu Start >> Run 2) Find the…

Read More

Determine User Role by Name in WordPress

This function returns the user role by name rather than by capabilities which is useful for determining whether the current user is a Wholesale customer for instance. It can also return the name of the user role given the user ID as a parameter. /** * Checks if a particular user has a role. *…

Read More

Check if Multi Content Block is Empty

Using Multiple Content Blocks by Trendwerks. Check if block has content and if not do something else such as default content: if (has_block(‘cta 3’)) { the_block(‘cta 3’); } else { // do something here echo do_shortcode(“[contentblock id=3] “); }  

Read More