Author Archive Widget in WordPress

In wordpress we can show the post archive widget easily but there is no easy way to show author archive widget. This small code snippet will help to show author archive widget in author page.


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’ );

if ( false === $result ) {

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

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

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

$cacheresult = wp_cache_set( ‘taxpostcount’.$id, $result, ‘cbtaxpostcount’ );
return $result;

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″]

Please check here .


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;
# Remove plugins feed
# Remove "WordPress News"
# Remove incoming links feed

// Now hook in to the action
add_action(‘wp_dashboard_setup’, ‘remove_dashboard_widgets’, 20, 0);

//better print_r function taken from
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>";
echo "</td></tr>";
echo "</table>";
echo $my_array;

Continue reading

Show/Hide comment status text in wordpress

I am again confused if my post title is perfect or not 🙁 So let me explain, sometimes we disable comment for any post or page and at last the text shows “Comments are closed” or something else in different ways. But in commercial projects we need to follow some good design where in some posts or pages we may need to enable comment or not. So, let’s put a trick in theme to show the comment text(comment status in more smart way)

In latest wordpress version the loop is in the loop.php file in the theme folder. So for comment we will get this line

[code language=”php”]
<?php comments_template( ”, true ); ?

But how about we put

[code language=”php”]
<?php if($post->comment_status == "open"){comments_template( ”, true );} ?>

That means if comment is off then we will not show any text like “Comments are closed” . I strongly believe this trick will make the design clean in some condition 😛

Thank you

How to Insert custom Quicktags into the WordPress Editor

WordPress has two type of editor, one is visual/wysiwyw that is tinymce or replace with other such editors and another is HTML editor that is we call quick tag editor. Today, I want to write something about how to add custom quick tags or custom buttons. I search about it in google and most guides to edit core quick tag javascript file. But I don’t like that and I made my own hack in my own way, though experts may think it’s childish 😛

So let come to point, I wanted to add some buttons that will give me option to add custom class name so that I can format the text well. Same thing can be done via Visual editor but you have to use a plugin named “Tinymce Advanced” which helps to add more advance buttons like styles(class lists) and so on. But for HTML mode or for quick tags editor I didn’t such plugins.
Continue reading