WordPress – Get a list of all user roles (existing in the site)

# WordPress – Get a list of all user roles (existing in the site) sometimes you need to see all of the user roles in your website, to do that Add this in functions.php: function get_editable_roles() { global $wp_roles; $all_roles = $wp_roles->roles; $editable_roles = apply_filters(‘editable_roles’, $all_roles); return $editable_roles; } Now, on some page of …


WordPress – Create a custom user role (and delete a role)

# WordPress – Create a custom user role Sometimes you want to create a special user with a special name and behavior inside WordPress The way to add a custom user role is the following: function add_capability() { // Add a custom user role (1) – Let’s say… God! $result = add_role( ‘god’, __(‘God’), …


WP Query Show Post Count when Paginating results

# WP Query Show Post Count when Paginating results Let’s say that you doing a custom query, and their is pagination in place, and you want to show : “Displaying 2 out of 5 results” (2 results on this page, and you have 5 total in all of the pages). The way to do …


WordPress – Change User Role name

# WordPress – Change User Role name in functions.php : function change_role_name() { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); //You can list all currently available roles like this… // This is only for you to see whats going on, after checking, remove these 2 lines altogether $roles …


WordPress – Contact Form 7 – Dynamic change fields

# WordPress – Contact Form 7 – Dynamic change fields yes you can use a plugin “something cf7 dynamic fields”, but their is a better way, or at least let’s call it, my way. We can change the fields via JavaScript on document ready… First of all Give the field an id (in contact …


WordPress – Creating a Child Theme, the pure basics

# WordPress – Creating a Child Theme, the pure basics A child theme consists of at least one directory (the child theme directory) that will be placed under the themes folder and two files (style.css and functions.php), which you will need to create: This is basically all you need to create a child theme. …


Fast WordPress Debug (Debug to console)

A fast way to debug that I use to debug in WordPress, In fact I got used to it so much that I use it on any PHP environment or framework that i work on. The method is debugging php variables and arrays to the console (the browser console) and will print out at …