Blog

Posts in "Code Snippet" category

How to add unit separator commas to numbers with jQuery

To format a number with jQuery to seperate its units with commas use the snippet below:

function ReplaceNumberWithCommas(yourNumber) {     var n= yourNumber.toString().split(".");     n[0] = n[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");     ...

see full post
tags:

How to remove the help tabs in WordPress Admin

Add the snippet below to your themes functions.php file remove the help tabs in WordPress Admin.

function remove_help_tabs() {     $screen = get_current_screen(); $screen->remove_help_tabs(); } add_action('admin_head', 'remove_help_tabs');

see full post
tags:

How to close any open tags in a PHP string

Use the snippet below to close any open tags in a PHP string.

function closetags($html) {     preg_match_all('#<(?!meta|img|br|hr|input\b)\b([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result);     $openedtags = $result[1];     preg_match_all('#</([a-z]+)>#iU', $html, ...

see full post
tags:

How to change the WordPress admin footer text

Add the snippet below to your themes functions.php file to change the WordPress admin footer text.

if (! function_exists('dashboard_footer') ){     function dashboard_footer () {         echo 'YOURTEXT'; ...

see full post
tags:

How to add featured images to a custom post type or page

This snippet will add featured images to a custom post type or page in WordPress.

Just add the code below to your themes functions.php file replacing “your_custom_post_type” with yours.

add_theme_support('post-thumbnails', array(     ...

see full post
tags:

welcome to the eudemonics blog ...

you can find posts about the things i've been working on, useful code snippets and articles relating to my interests.

comments can be left at the bottom of each post, if you wish to contribute to an article please get in touch.

Blog Categories

Blog Tags