Search User by Display Name in WordPress Sitewide

In wordpress in backend or if you use wordpress user query ‘WP_User_Query’ by default it will not search by display_name even if you add display_name in “search_columns” field of WP_User_Query
So, this can be achieved by this small filter https://gist.github.com/manchumahara/9910185 (after add this code now if you search in your wordpress admin panel for user with their display name it will work)

ref: https://codex.wordpress.org/Class_Reference/WP_User_Query

Category Post Count in WordPress (Custom Taxonomy with Custom Post Type)

Let me explain my need in short:

I want to show post count for any category/any custom taxonomy registered for any custom post type. I searched wordpress forums and in google, found some solutions using

Nothing helped me such way, so I managed my own way with my little knowledge.

wp_get_productcat_postcount($id, $posttype = ‘product’, $taxname = ‘product_cat’)

$id = category or any taxonomy id(term id)
$posttype = post type name, example: post, page, or any custom post type
$taxname = taxonomy name or any category type name, for joomla default taxonomy it will category, post_tag, nav_menu, link_category, post_format, but we can use any custom taxonomy name as I used ‘product_cat’ which is used with custom post type ‘product’ , post type name.

[code lang=”php”]
function wp_get_productcat_postcount($id, $posttype = ‘product’, $taxname = ‘product_cat’) {

$result = wp_cache_get( ‘taxpostcount’.$id, ‘cbtaxpostcount’ );
//var_dump($resul);

if ( false === $result ) {

$args = array(
‘post_type’ => $posttype,
‘post_status’ => ‘publish’,
‘posts_per_page’ => -1,
‘tax_query’ => array(
‘relation’ => ‘AND’,
array(
‘taxonomy’ => $taxname,
‘field’ => ‘id’,
‘terms’ => array( $id )
)
)
);

$query = new WP_Query( $args);
/*
echo ‘<pre>’;

print_r($query->post_count);
echo ‘</pre>’;
*/
$result = (int)$query->post_count;

$cacheresult = wp_cache_set( ‘taxpostcount’.$id, $result, ‘cbtaxpostcount’ );
//var_dump($cacheresult);
}
return $result;
}
[/code]

Note: As I used wordpress object cache for better performance.

Thanks for reading, any comment is appreciable.

Google Plus Comment for WordPress

Google Plus Introduced Social comment plugin(unofficially). so I just made a small shortcode based plugin for wordpress to test the baby.

BTW, I noticed about this from google plus.

Download from bellow:

[download id=”36″]

Demo:
Please check here .

Shortcode:
[gpluscomment]

For more technical people
'url' => '', // leave empty for current post
'width' => '500',
'js' => 1,
'showarchive' => false,
'showhome' => false

My Test results screenshots:

āφāϏ⧁āύ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄāĻĒā§āϰ⧇āϏ⧇āϰ āĻĄā§āϝāĻžāĻļ āĻŦā§‹āĻ°ā§āĻĄ āĻĒāϰāĻŋāĻ¸ā§āĻ•āĻžāϰ āĻ•āϰāĻŋ

āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄāĻĒā§āϰ⧇āϏ⧇āϰ āĻāĻĄāĻŽāĻŋāύ āĻĒā§āϝāĻžāύ⧇āϞ⧇ āϞāĻ—āĻŋāύ āĻ•āϰāϞ⧇āχ āĻāĻ•āĻ—āĻžāĻĻāĻž āĻŦāĻ•ā§āϏ āĻāϏ⧇ āĻšāĻžāϜāĻŋāϰ āĻšāϝāĻŧāĨ¤ āϝāĻĻāĻŋāĻ“ āĻ¸ā§āĻ•ā§āϰāĻŋāύ āĻ…āĻĒāĻļāύ āĻĨ⧇āϕ⧇ āϏ⧇āϗ⧁āϞ⧋ āϏāĻšāĻœā§‡ āϤāĻžāĻĄāĻŧāĻžāύ⧋ āϝāĻžāϝāĻŧ āĻ•āĻŋāĻ¨ā§āϤ⧁ āϝāĻĻāĻŋ āĻāĻŽāύ āĻšāϝāĻŧ āĻāĻĄāĻŽāĻŋāύ āύāĻŋāĻœā§‡āχ āĻĄā§āϝāĻžāĻļāĻŦā§‹āĻ°ā§āĻĄ āĻĒāϰāĻŋāĻ¸ā§āĻ•āĻžāϰ āĻ•āϰ⧇ āϰ⧇āϖ⧇ āĻĻāĻŋāϞ⧇āύ āύāϤ⧁āύ āϏāĻĻāĻ¸ā§āϝ⧇āϰ āϜāĻ¨ā§āϝāĨ¤ āϤāĻŦ⧇ āĻāχ āĻĒāϰāĻŋāĻ¸ā§āĻ•āĻžāϰ āĻāϰ āĻ•āĻžāϜāϟāĻž āφāĻŽāϰāĻž āĻ•āϰāĻŦā§‹ āϏāĻžāĻŽāĻžāĻ¨ā§āϝ āĻ•āĻŋāϛ⧁ āĻĒāĻŋāĻāχāϚāĻĒāĻŋ āϕ⧋āĻĄāĻŋāĻ‚ āĻ•āϰ⧇āĨ¤

āϧāĻžāĻĒ āĻāĻ•āσ āĻĒā§āϰāĻĨāĻŽā§‡ āφāĻĒāύāĻžāϰ āĻĨā§€āĻŽā§‡āϰ functions.php āĻĢāĻžāχāϞ⧇ āĻ ⧍āϟāĻŋ āĻĢāĻžāĻ‚āĻļāύ āϞāĻŋāĻ–āϤ⧇ āĻšāĻŦ⧇āĨ¤ āĻŽāύ⧇ āϰāĻžāĻ–āĻŦ⧇āύ āĻĒā§āϞāĻžāĻ—āĻŋāύ āĻāϰ āϕ⧋āĻĄāϗ⧁āϞ⧋ āϚāĻžāχāϞ⧇ functions.php āĻĢāĻžāχāϞ⧇āĻ“ āϞ⧇āĻ–āĻž āϝāĻžāϝāĻŧāĨ¤ āϤāĻžāĻšāϞ⧇ āĻļ⧁āϰ⧁ āĻ•āϰāĻž āϝāĻžāĻ•āσ
[code language=”php”]
//Define the function which unsets the boxes
function remove_dashboard_widgets() {
global $wp_meta_boxes;
myprint_r($wp_meta_boxes);
/*
//unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_right_now’]);
# Remove plugins feed
unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_plugins’]);
unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_plugins’]);
# Remove "WordPress News"
unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_primary’]);
unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_primary’]);
unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_secondary’]);
unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_secondary’]);
# Remove incoming links feed
unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_incoming_links’]);
unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_incoming_links’]);

unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_recent_drafts’]);
unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_recent_comments’]);
unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_quick_press’]);
unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘events_dashboard_window’]);
*/
}
// Now hook in to the action
add_action(‘wp_dashboard_setup’, ‘remove_dashboard_widgets’, 20, 0);

//better print_r function taken from
//http://stackoverflow.com/questions/1386331/php-print-r-nice-table
function myprint_r($my_array) {
if (is_array($my_array)) {
echo "<table border=1 cellspacing=0 cellpadding=3 width=100%>";
echo ‘<tr><td colspan=2 style="background-color:#333333;"><strong><font color=white>ARRAY</font></strong></td></tr>’;
foreach ($my_array as $k => $v) {
echo ‘<tr><td valign="top" style="width:40px;background-color:#F0F0F0;">’;
echo ‘<strong>’ . $k . "</strong></td><td>";
myprint_r($v);
echo "</td></tr>";
}
echo "</table>";
return;
}
echo $my_array;
}

[/code]
Continue reading