Monthly Archive: January 2016

0

WordPress Function to Return the number of comments

Return the number of comments This is like count_user_posts(), but returns the number of comments instead: function count_user_comments($id) { global $wpdb; $users = $wpdb->get_var(” SELECT COUNT( * ) AS total FROM $wpdb->comments WHERE comment_approved...

0

WordPress Function to Extending Auto Logout Period

Extending Auto Logout Period Tested on: WordPress 3.0.1 Using the code below you can increase the time cookies are kept and therefor users who are logged in remain logged in longer: function keep_me_logged_in_for_1_year( $expirein...

0

WordPress Function to Grab all custom fields globally

Grab all custom fields globally function get_custom_field($key, $echo = FALSE) { global $post; $custom_field = get_post_meta( $post->ID, $key, true ); if ( $echo == false ) return $custom_field; echo $custom_field; } Then call the...

0

WordPress Function to Remove Private and Protected Prefix

Remove Private and Protected Prefix This function removes the “Privite:” prefix from posts and pages marked private. Useful for content only visible to logged in users or groups. function the_title_trim($title) { $title = attribute_escape($title);...

0

WordPress Function to Enable oEmbed in Text/HTML Widgets

Enable oEmbed in Text/HTML Widgets add_filter( ‘widget_text’, array( $wp_embed, ‘run_shortcode’ ), 8 ); add_filter( ‘widget_text’, array( $wp_embed, ‘autoembed’), 8 ); I use this for youtube video widgets and flickr stuff.