notes

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

International Online Database of Registered Trade Marks -Scam

We recently received an unsolicited letter from IDRTM (International Database of Registered Trademarks) asking for the princely sum of $1,638 to include one of our Trade Marks in their online database. They do indeed have a website on which you can search for trade marks etc but you have to ask yourself why would you…

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

Check for Featured Image and Display It With The Caption

First check for the existence of the image then display it in the content area: In the template us this: // check if the post has a Post Thumbnail assigned to it. if ( has_post_thumbnail() ) { the_post_thumbnail(); } This defaults to the Thumbnail size under Settings. Size can be set by adding sizing parameters…

Read More

Resizing Facebook Like Buttons Using CSS

The standard Facebook Like button is pretty small so you might want to enlarge it but there is no means to do so using the Facebook API to generate the button code. Instead this is achieved using CSS on the .fb-like class that Facebook adds to the standard “Like” button. It uses the Transform property…

Read More

Cool Video Gallery. Gallery Not Found Error

Cool Video Gallery by Praveen Rajan The ‘Gallery not Found’ error message occurs after upgrading the WordPress Core to 4 and above. The plugin itself hasn’t been updated since May 2014 and the details show compatibility up to WordPress 3.9 so this is a fix that hopefully will be included in the next plugin update.…

Read More

WP E-Commerce Custom Fields used in Conditional Statements

WP E-Commerce Custom Fields plugin enables custom meta fields to be added to all the products edit page. Install the plugin from here: https://wordpress.org/plugins/wp-e-commerce-custom-fields/ Once installed these custom fields are defined under the Products >> Attributes menu. Create the attribute then assign values in the individual product admin pages. To show the value of the…

Read More

CSS Attribute and Adjacent Sibling Selectors

Useful attribute selectors available in CSS3 for complete and partial matching of attribute values: This example uses the title attribute of the H1 tag: h1[title=”Home”] { color: blue; } /*Exact value “Home” in the title attribute */ h1[title~=”Home Back”] { color: red; } /* Attribute equals one of the list.*/ h1[title^=”Home”] {color: green; } /*Title…

Read More

Override WordPress Options using a Filter

The basic format for the add_filter function is: add_filter(‘pre_option_’.$option, ‘override_function_name’); Where $option is the name of the Option as found in the wp_options table of the database. This example uses a filter to update the admin_email set in Options to that of the current user, so ‘admin_email’ becomes ‘pre_option_admin_email’. add_filter(‘pre_option_admin_email’, ‘override_option_admin_email’); function override_option_admin_email() { global…

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