Blog Archives

Speed up WP_Query

In WordPress, when a query does not need paging and you only want a limited amount of results, like the last 5 posts, set the ‘no_rows_found’ parameter to true.  This prevents WordPress from doing additional work in counting the total matched rows,

Posted in Coding Tagged with:

Disable Responsive Images in WordPress

In WordPress 4.4 images are displayed with the srcset attribute.  This attribute allows the browser to select alternative images for best viewing.  Sometimes though this may not be wanted as the image being displayed is the only image you want to show

Posted in Coding Tagged with:

Escape strings for use in JavaScript

When using parameters from the URL, it should always be sanitized before using it in your javascript. Using jQuery you can easily do: var safeString = $(“<span></span>”).text(unsafeString).html(); Using plain javascript: var entityMap = { “&”: “&amp;”, “<“: “&lt;”, “>”: “&gt;”,

Posted in Coding Tagged with: , ,

Left Sidebar Under Content

Problem Having a left sidebar move under the content in a responsive design needs a bit more thinking.  You can’t just do float left width 100% or display block and let the sidebar fall to the next line. Solution When

Posted in Coding Tagged with: ,

Run WP-Cron with no visitors

Got a website with noone visits or simply a website that is private but still need WP-Cron to be run?  no problem, you have 2 easy options. 1) Setup a free account with set https://www.setcronjob.com ( i like them better because they

Posted in Coding Tagged with:

Order Non-hierarchical Custom Post Types

Non-hierarchical post types are like regular posts which normally do not have a menu_order attribute.  Hierarchical post type are like pages which allows a parent/child and is normally ordered by the menu_order attribute.  What if you have a custom post type that

Posted in Coding Tagged with: ,

iPad textarea not selectable

Problem The textarea on iPad could not be selected and could not have anything entered. Solution The textarea in iPad only responds to the ‘touchstart’ event and not the ‘click’ event, but regular input accepts the ‘click’ apparently.  I some javascript where it would catch

Posted in Coding Tagged with: , ,

What keyboard does an HTML input bring up?

I was having trouble figuring out what input type brings up what keyboard on the iPhone and iPad.  Turns out the number type doesn’t bring up the numeric pad.  Only “tel” does. This is a great article on what input

Posted in Coding Tagged with: , , , ,

Line in Firefox background

Problem When scaling the FireFox and having a background image size set to 100%, the bottom of the image sometimes shows a line on the bottom showing the background behind it. Solution Firefox seems to have a problem with background-size: 100%.  instead

Posted in Coding Tagged with: ,

2 color horizontally expanding background

All done in css, no images.  Float the background past the normal page width based on percentage.  one on the left, one on the right.   http://stackoverflow.com/questions/8893312/css-bi-color-flexible-horizontal-background-band

Posted in Coding Tagged with: