Tag: wordpress

WordPress REST API schema property format: email

Problem:  When setting a property type to ’email’ like so: $schema = array( ‘$schema’ => ‘http://json-schema.org/schema#’, ‘title’ => ‘user’, ‘type’ => ‘object’, ‘properties’ => array( ’email’ => array( ‘description’ => __( ‘The optional email address for the something.’ ), ‘type’

Posted in Coding Tagged with: ,

WordPress 4.6 crashed my site

Fatal error: Cannot redeclare the_post_thumbnail_caption() (previously declared in …. This error occurs because the_post_thumbnail_caption is a new function in WordPress 4.6.  However, people have been using this function for over 5 years now.  How?  Stackoverflow and other WordPress forums are flooded with

Posted in Coding Tagged with: ,

WordPress the_title filter changed in nav menus

I haven’t had time to look into the exact reason or the exact version this changed, but as of at least WordPress version 4.5.2 the nav menu uses the_title multiple times for one item. For example if your theme used something like

Posted in Coding Tagged with:

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_found_rows’ 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:

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: ,

Easy Way to Add a Class to a Menu Item in WordPress

Go to Appearance -> Menus.  Open up Screen Options in the top right.  Click on the CSS Classes checkbox under Show Advanced menu properties.  Now each menu item has a textbox where you can enter css classes.

Posted in Coding Tagged with:

WordPress Heartbeat API

I could not find any extensive documentation on the WordPress Heartbeat API, so I am writing here to remember what I have learned through various tutorials throughout the web. The Heartbeat API is written in Javascript.  Think of it like a

Posted in Coding Tagged with: , ,

edit_users capability on multisite

No matter how hard you try, if you add the edit_user capability to a user on multi-site and that user is not a super-admin, the user will not have the edit_user capability.  This is hard-coded into WP_User’s map_meta_cap.  There is a filter

Posted in Coding Tagged with: ,