WordPress blog posts

highlight search terms in search results

To highlight search terms in the search results you can use the code below. Additionaly you will need to give search-highlight some special properties in your style sheet.

Warning: The type attribute is unnecessary for JavaScript resources.

By default WordPress adds scripts by using the type attribute enqueing styles and scripts, the latest html validators throw a warning because this is redundent/ unnecessary Exmaple Here is an example of the default way WordPress includes scripts  


PHPStorm – remove div with class

In a search and replace project we had to remove one div from 1000+ static html pages. We knew the id (container) and class (nav) it had and the class of the div (class is fullWithBlock) that followed that specific div on every page

Output array() as html table with keys as colomn header

This function returns every array() as html table.

Checkout: custom date field

In this situation we want a custom field on checkout which has a jQuery Date selector:

Checkout: give a discount for local pickup

I had to add a discount for local pickup and at first this looked easy. You can set the costs to be a negative amount. But if the subtotal for the order was smaller then the discount, they got the order for free. So I wanted the discount only if the order subtotal was more […]

Track external links with google Analytics – no tagmanager needed

You most likely have the analytics script on your site already. There are a few versions and this one uses the _gaq.push one not the ga(…)

One stop redirect https and www

If you want a redirect to the www version and a redirect to the https version of your blog, you might add rules to redirect those situations. On any pageload test this kan be punished if it detects tworedirect (both to www and https). To be save time and score, do both redirects in one […]

Copyright notice with current year

This line shows a copyright notice with the current year. Add it in your WordPress theme template somwhere.