WordPress: How to Check if the is_front_page a page ?

In WordPress reading option if you select page as home then that is called frontend page technically and in that is_home() returns false as it’s not the actual archive page home page that we find default. There is another helper function in wordpress to check if regular or page based home using is_front_page() but if you check in plugin or theme using is_front_page() it will return true for both regular archive home or frontpage based home page(if you set a page as home). So, how can we check if the home page is page based front page or archive base front page or home ?

https://gist.github.com/manchumahara/9112df535b704409bc4ba24311c540d6

First Time Became WordPress Core Contributor

āĻāĻ•āϟāĻž āĻĢāĻžāĻ‚āĻļāύ⧇ āĻāĻ•āϟāĻž āĻ…āϤāĻŋāϰāĻŋāĻ•ā§āϤ āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ āϝ⧁āĻ•ā§āϤ āĻ•āϰ⧇ āĻšā§Ÿā§‡ āϗ⧇āϞāĻžāĻŽ āĻ“ā§ŸāĻžāĻ°ā§āĻĄāĻĒā§āϰ⧇āϏ 4.9 āĻāϰ āϕ⧋āϰ āĻ•āĻ¨ā§āĻŸā§āϰāĻŋāĻŦāĻŋāωāϟāĻžāϰ 🙂

āφāĻŽāĻŋ āĻ…āĻŦāĻļā§āϝāχ āĻŦāϞāϤ⧇ āϚāĻžāχ āĻ“ā§ŸāĻžāĻ°ā§āĻĄāĻĒā§āϰ⧇āϏ āĻāϰ āϕ⧋āϰ āĻ•āĻŽāĻŋāϟāĻžāϰāϰāĻž āϖ⧁āĻŦāχ āφāĻ¨ā§āϤāϰāĻŋāĻ• āĻāĻŦāĻ‚ āĻšā§‡āĻ˛ā§āĻĒāĻĢ⧁āϞāĨ¤ āĻ…āĻ¨ā§āϤāϤ āφāĻĒāύāĻŋ āϕ⧋āύ āχāĻ¸ā§āϝ⧁ āĻĒā§‹āĻ¸ā§āϟ āĻ•āϰāϞ⧇ āĻĻā§āϰ⧁āϤ āωāĻ¤ā§āϤāϰ āĻĒāĻžāĻŦ⧇āύ, āϕ⧋āύ āĻĒā§āϝāĻžāϚ āĻĒāĻžāĻ āĻžāϞ⧇ āĻĻā§āϰ⧁āϤ āϝāĻžāϚāĻžāχ āĻ•āϰ⧇āĨ¤ āĻ…āĻ¨ā§āϝāϰāĻž āϝāĻžāϰāĻž āϕ⧋āϰ āĻ•āĻŽāĻŋāϟāĻžāϰ āύāĻž āĻ•āĻŋāĻ¨ā§āϤ⧁ āϰ⧇āϗ⧁āϞāĻžāϰ āχāĻ¸ā§āϝ⧁ āϗ⧁āϞ⧋āϤ⧇ āĻ•āĻ¨ā§āĻŸā§āϰāĻŋāĻŦāĻŋāωāϟ āĻ•āϰ⧇ āϤāĻžāϰāĻž āφāĻĒāύāĻžāϕ⧇ āϏāĻžāĻšāĻžāĻ¯ā§āϝ āĻ•āϰāĻŦ⧇āĨ¤

āϝ⧇ āϕ⧇āω https://core.trac.wordpress.org/ āĻāĻ–āĻžāύ⧇ āĻ—āĻŋā§Ÿā§‡ āĻ“ā§ŸāĻžāĻ°ā§āĻĄāĻĒā§āϰ⧇āϏ āĻāϰ āϕ⧋āϰ⧇āϰ āϕ⧋āύ āĻŦāĻžāĻ— āĻĒ⧇āϞ⧇ āχāĻ¸ā§āϝ⧁ āϏāĻžāĻŦāĻŽāĻŋāϟ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύāĨ¤ āϝāĻĻāĻŋ āφāĻĒāύāĻŋ āϜāĻžāύ⧇āύ āĻĢāĻŋāĻ•ā§āϏ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ āĻ•āĻŋ āϧāϰāύ⧇āϰ āϕ⧋āĻĄ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻĻāϰāĻ•āĻžāϰ āϤāĻžāĻšāϞ⧇ āϤāĻž āĻ•āϰ⧇ āĻĒā§āϝāĻžāϚ āφāĻ•āĻžāϰ⧇ āϏāĻžāĻŦāĻŽāĻŋāϟ āĻ•āϰāϤ⧇ āĻšāĻŦ⧇āĨ¤

āĻ…āύ⧇āĻ• āϏāĻŽā§Ÿ āϝāĻ–āύ āφāĻĒāύāĻŋ āĻ•āĻžāĻ¸ā§āϟāĻŽ āĻ•āĻŋāϛ⧁ āĻŦāĻžāύāĻžāĻšā§āϛ⧇āύ āĻšā§ŸāϤ⧋ āĻĻ⧇āĻ–āϛ⧇āύ āϕ⧋āϰ āϕ⧋āĻĄā§‡ āύāϤ⧁āύ āϕ⧋āύ āĻšā§āĻ• āϝ⧁āĻ•ā§āϤ āĻšāϞ⧇ āϏ⧁āĻŦāĻŋāϧāĻž āĻšāĻŦ⧇ āĻŦāĻž āϕ⧋āύ āĻšā§āϕ⧇ āύāϤ⧁āύ āĻāĻ•āϟāĻž āĻĒā§āϝāĻžāϰāĻžāĻŽāĻŋāϟāĻžāϰ āĻĨāĻžāĻ•āĻž āϝ⧁āĻ•ā§āϤāĻŋāϝ⧁āĻ•ā§āϤ āφāĻĒāύāĻŋ āϏ⧇āχ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇ āĻĒā§āϝāĻžāϚ āϏāĻžāĻŦāĻŽāĻŋāϟ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύāĨ¤ āĻ—ā§āϰāĻšāύāϝ⧋āĻ—ā§āϝ āϝ⧇ āϕ⧋āύ āĻ•āĻŋāϛ⧁ āϖ⧁āĻŦ āϝāĻ¤ā§āύ⧇āϰ āϏāĻžāĻĨ⧇ āĻ“ā§ŸāĻžāĻ°ā§āĻĄāĻĒā§āϰ⧇āϏ āĻāĻ•ā§āϏ⧇āĻĒā§āϟ āĻ•āϰ⧇ āĻāĻŦāĻ‚ āĻŦāĻŋāώ⧟āϟāĻž āĻĻā§āϰ⧁āϤāĨ¤ āφāĻĒāύāĻžāϕ⧇ āϕ⧋āύ āĻĒ⧇āχāύ āĻāϰ āϭ⧇āϤāϰ āĻĻāĻŋā§Ÿā§‡ āϝ⧇āϤ⧇ āĻšāĻŦ⧇ āύāĻž āĻāĻŦāĻ‚ āĻŽāύ⧇ āĻšāĻŦ⧇ āύāĻž āϝ⧇ āϕ⧇āω āφāĻĒāύāĻžāϰ āϰ⧇āĻ•ā§Ÿā§‡āĻ¸ā§āϟ āύāϜāϰ⧇āχ āφāύāϛ⧇ āύāĻžāĨ¤

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: