WordPress ScrollTo Hash

October 31, 2017 (6 years ago)
JS, WordPress

I needed to pass a hash, and scroll to the matching anchor on a new page.

Not as easy as it sounds in WordPress. (Pretty permalinks make it not work.)

After much testing and research, here’s the solution that worked best:

I added the “-150” after the offset to show the header above the anchor.

WooCommerce – Conditional Ship to a Different Address Selection

October 31, 2017 (6 years ago)
Functions, JS, WooCommerce, WordPress

The scenario is this:

The site has multiple shipping methods (multiple client locations, and the option to ship to “Other”.)

I wanted to show the address panel if “Other” location was chosen, and hide the “Ship to Another Location”  option heading on the shipping page if a client location was chosen.

None of this was strictly necessary, but it makes for a smoother customer experience.

This went into my functions.php file.

Then, this is the hide_ship_to.js script file. (uploaded to the theme directory)

 

A Simple jQuery Accordion

February 27, 2017 (7 years ago)
Functions, JS

No need for the overhead of a plugin.

In this case, I have a custom post type for FAQs, where the title is the question, and the content is the answer.

This script hides all the answers until one of the questions is clicked.

Here’s the JavaScript:

And the HTML:

 

Then, this little bit of CSS brings it together:

 

Remove Emoji Support from WordPress 4.2

May 19, 2015 (9 years ago)
Functions, JS, WordPress

4.2 added the ability to use Emojicons in WP posts. If you don’t use them, you can remove the (unnecessary) scripts this adds to the header on all your site pages. Here’s the code for your functions.php file:

 Thank you, Paulund!

http://www.paulund.co.uk/disable-emojicons-introduced-in-wordpress-4-2