হয়ে যান সুপার হিরো-ওয়ার্ডপ্রেসে প্লাগিন পরিহার করুন

সব কাজ যদি প্লাগিন দিয়ে করতে যান তবে সাইটে প্রচুর প্লাগিন লাগবে আর এতে সুফল থেকে কুফল বয়ে আনবে বেশি,চলুন কিছু কাজ ডাইরেক্ট কোডিং করেই করি।

= সতর্কবাণী =

*সকল আপডেটের আসে ব্যাক আপ নিন,অথবা শুধু ওই ফাইলের ব্যাকআপ রাখুন।

** কেউ এখন থেকে কোড কপি করবেন না,দেখে দেখে নিজের হাতে কোড লেখার অভ্যাস করুন।

১। মেমরি সীমা বৃদ্ধি

আপনার সাইটের প্রচুর ভিজিটর থাকলে মেমরি সাইজ বাড়িয়ে নিন

এই কোডটি wp-config ফাইলে লিখুন


define('WP_MEMORY_LIMIT', '96M');

২ । প্রতিটি টিউনের শেষে লেখক তথ্য বক্সে

এটি single.php তে লিখুন

ছবি

<?php echo get_avatar( get_the_author_email(), $size = '100' ); ?>

লেখকের ওয়েবসাইট লিংক

<a href="<?php the_author_url(); ?>">Author’s Website</a>

লেখকের ইনফো

<?php the_author_description(); ?>

৩। মন্তব্য করার জন্য HTML নিষ্ক্রিয় করুন

এটি থীমসের functions.php তে লিখুন

// This will occur when the comment is posted
function plc_comment_post( $incoming_comment ) {

// convert everything in a comment to display literally
$incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']);

// the one exception is single quotes, which cannot be #039; because WordPress marks it as spam
$incoming_comment['comment_content'] = str_replace( "'", '&apos;', $incoming_comment['comment_content'] );

return( $incoming_comment );
}

// This will occur before a comment is displayed
function plc_comment_display( $comment_to_display ) {

// Put the single quotes back in
$comment_to_display = str_replace( '&apos;', "'", $comment_to_display );

return $comment_to_display;
}

add_filter( 'preprocess_comment', 'plc_comment_post', '', 1);
add_filter( 'comment_text', 'plc_comment_display', '', 1);
add_filter( 'comment_text_rss', 'plc_comment_display', '', 1);
add_filter( 'comment_excerpt', 'plc_comment_display', '', 1);

৪। বিজ্ঞাপন শুধুমাত্র সার্চ ইঞ্জিন হতে আসা ভিজিটরকে দেখান

এটি থীমসের functions.php তে লিখুন

function scratch99_fromasearchengine(){
$ref = $_SERVER['HTTP_REFERER'];
$SE = array('/search?', 'images.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.');
foreach ($SE as $source) {
if (strpos($ref,$source)!==false) return true;
}
return false;
}

তারপর আপনার থিমের যেখানে আপনি AdSense ব্লক দৃশ্যমান যোগ করতে চান

if (function_exists('scratch99_fromasearchengine')) {
 	  if (scratch99_fromasearchengine()) {
 	    INSERT YOUR CODE HERE
 	  }
 	}

৫। সর্বশেষ পোস্ট দেখাতে

এটি সাইটবারে অথবা ফুটরে দিতে পারেন

<?php query_posts('showposts=5'); ?>

<ul>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
</ul>

আমি ৫টি পোষ্ট করে দিয়েছি আপনি চাইলে বাড়াতে পারেন।

৬।আপনার থিমে থেকে একটা লগইন বক্স যোগ করুন

এটি আপনার ইচ্ছামত যেকোন স্থানে বসাতে পারেন যেমন,সাইডবারে

<li>
<?php global $user_ID, $user_identity, $user_level ?>
<?php if ( $user_ID ) : ?>
<h2>Control panel</h2>
<ul>
<li>Identified as <strong><?php echo $user_identity ?></strong>.
<ul>
<li><a href="<?php bloginfo('url') ?>/wp-admin/">Dashboard</a></li>
<?php if ( $user_level >= 1 ) : ?>
<li><a href="<?php bloginfo('url') ?>/wp-admin/post-new.php">Write an article</a></li>
<?php endif // $user_level >= 1 ?>
<li><a href="<?php bloginfo('url') ?>/wp-admin/profile.php">Profile and personal options</a></li>
<li><a href="<?php bloginfo('url') ?>/wp-login.php?action=logout&amp;redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']) ?>">Exit</a></li>
</ul>
</li>
</ul>
<?php elseif ( get_option('users_can_register') ) : ?>
<h2>Identification</h2>
<ul>
<li>
<form action="<?php bloginfo('url') ?>/wp-login.php" method="post">
<p>
<label for="log"><input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="22" /> User</label><br />
<label for="pwd"><input type="password" name="pwd" id="pwd" size="22" /> Password</label><br />
<input type="submit" name="submit" value="Send" />
<label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> Remember me</label><br />
</p>
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/>
</form>
</li>
<li><a href="<?php bloginfo('url') ?>/wp-register.php">Register</a></li>
<li><a href="<?php bloginfo('url') ?>/wp-login.php?action=lostpassword">Recover password</a></li>
</ul>
<?php endif // get_option('users_can_register') ?>
</li>

৭। টুইটারের মত time ago যোগ করুন

এটি single.php এবং হেডার ফাইলে টিউন টাইটেলের পরে বসান

পোষ্ট এবং পেউজের ক্ষেত্রে :

<?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago'; ?>

কমেন্টস এর জন্য :

<?php echo human_time_diff(get_comment_time('U'), current_time('timestamp')) . ' ago'; ?>

৮। আপনার পোস্টে স্বয়ংক্রিয়ভাবে গুগুল বাটন যোগ করুন

নিচের কোডটি functions.php তে লিখুন

add_filter('the_content', 'wpr_google_plusone'); function wpr_google_plusone($content) { $content = $content.'<div><g:plusone size="tall" href="'.get_permalink().'"></g:plusone></div>'; return $content; } add_action ('wp_enqueue_scripts','wpr_google_plusone_script'); function wpr_google_plusone_script() { wp_enqueue_script('google-plusone', 'https://apis.google.com/js/plusone.js', array(), null); }

৯। প্লাগইন ব্যবহার না করেই পোস্ট ট্র্যাক করুন

এটি functions.php ফাইলে লিখুন

function getPostViews($postID){ $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0 View"; } return $count.' Views'; } function setPostViews($postID) { $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } }

এবার এটি single.php তে লিখুন

<?php setPostViews(get_the_ID()); ?>

এরপর এটি যেখানে আপনি ফলাপল দেখতে চান সেখানে লিখূন

<?php echo getPostViews(get_the_ID()); ?>

১০। সম্পূর্ণ টেক্সট হিসেবে ফেসবুকের ফ্যান সংখ্যা প্রদর্শন

এটি থীমসের যেখানে আপনি দেখতে চান সেখানে লিখুন

<?php $page_id = "YOUR PAGE-ID"; $xml = @simplexml_load_file("http://api.facebook.com/restserver.php?method=facebook.fql.query&query=SELECT%20fan_count%20FROM%20page%20WHERE%20page_id=".$page_id."") or die ("a lot"); $fans = $xml->page->fan_count; echo $fans; ?>

১১। গুগল অনুসন্ধানের ফলাফল প্রদর্শন

এটি আপনার সাইটের যেকোন স্থানে বসালে ভিজিটর নিজেই দেখতে পাবে সে গুগলে কি লিখলে আপনার সাইটের সন্ধান পেয়েছে,যেমন bdweblab.com লিখে গুগলে সার্চ দিন এবং সাইটে প্রবেশ করুন আর ফুটরে দেখুন আপনাকে কি দেখাচ্ছে

<?php $refer = $_SERVER["HTTP_REFERER"]; if (strpos($refer, "google")) { $refer_string = parse_url($refer, PHP_URL_QUERY); parse_str($refer_string, $vars); $search_terms = $vars['q']; echo 'Welcome Google visitor! You searched for the following terms to get here: '; echo $search_terms; }; ?

১২ । অটোমেটিক ভাবেই contributors দের ইমেল করুন যখন তাদের পোস্ট প্রকাশিত হয়।

এটি function.php তে লিখুন

function wpr_authorNotification($post_id) { $post = get_post($post_id); $author = get_userdata($post->post_author); $message = " Hi ".$author->display_name.", Your post, ".$post->post_title." has just been published. Well done! "; wp_mail($author->user_email, "Your article is online", $message); } add_action('publish_post', 'wpr_authorNotification');

১৩। আপনার নেটয়ার্ক সাইট সমূহের তালিকা দেখান সবাইকে

এটি থীমসের function.php তে লিখুন

function wp_list_sites( $expires = 7200 ) { if( !is_multisite() ) return false; // Because the get_blog_list() function is currently flagged as deprecated // due to the potential for high consumption of resources, we'll use // $wpdb to roll out our own SQL query instead. Because the query can be // memory-intensive, we'll store the results using the Transients API if ( false === ( $site_list = get_transient( 'multisite_site_list' ) ) ) { global $wpdb; $site_list = $wpdb->get_results( $wpdb->prepare('SELECT * FROM wp_blogs ORDER BY blog_id') ); // Set the Transient cache to expire every two hours set_site_transient( 'multisite_site_list', $site_list, $expires ); } $current_site_url = get_site_url( get_current_blog_id() ); $html = ' <ul id="network-menu">' . "\n"; foreach ( $site_list as $site ) { switch_to_blog( $site->blog_id ); $class = ( home_url() == $current_site_url ) ? '' : ''; $html .= "\t" . ' <li id="site-' . $site->blog_id . '" '="" .="" $class=""><a href="' . home_url() . '">' . get_bloginfo('name') . '</a></li> ' . "\n"; restore_current_blog(); } $html .= '</ul> <!--// end #network-menu -->' . "\n\n"; return $html;

এবার আপনি যেখানে প্রদর্শন করাতে চান সেখানে এটি লিখুন

<?php // Multisite Network Menu $network_menu = wp_list_sites(); if( $network_menu ): ?> <div id="network-menu"> <?php echo $network_menu; ?> </div> <!--// end #network-menu --> <?php endif; ?>

১৪।একটি Paypal দান লিংক সহজেই যোগ করুন

এটি function.php তে লিখুন

function cwc_donate_shortcode( $atts ) { extract(shortcode_atts(array( 'text' => 'Make a donation', 'account' => 'REPLACE ME', 'for' => '', ), $atts)); global $post; if (!$for) $for = str_replace(" ","+",$post->post_title); return '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business='.$account.'&item_name=Donation+for+'.$for.'">'.$text.'</a>'; } add_shortcode('donate', 'cwc_donate_shortcode');

১৫।প্রাইবেট পোস্ট তৈরী করুন আর শুধু রেজিষ্টার করাদের দেখতে দিন

এটি function.php তে লিখুন

function cwc_member_check_shortcode( $atts, $content = null ) { if ( is_user_logged_in() && !is_null( $content ) && !is_feed() ) return $content; return ''; } add_shortcode( 'member', 'cwc_member_check_shortcode' );

এবার লিখুন
টিউনের নিচে লিখুন

[member]This text will be only displayed to registered users.[/member]

১৬। Youtube ভিডিও যুক্ত করতে

এটি function.php তে লিখুন

function cwc_youtube($atts) { extract(shortcode_atts(array( "value" => 'http://', "width" => '475', "height" => '350', "name"=> 'movie', "allowFullScreen" => 'true', "allowScriptAccess"=>'always', ), $atts)); return '<object style="height: '.$height.'px; width: '.$width.'px"><param name="'.$name.'" value="'.$value.'"><param name="allowFullScreen" value="'.$allowFullScreen.'"></param><param name="allowScriptAccess" value="'.$allowScriptAccess.'"></param><embed src="'.$value.'" type="application/x-shockwave-flash" allowfullscreen="'.$allowFullScreen.'" allowScriptAccess="'.$allowScriptAccess.'" width="'.$width.'" height="'.$height.'"></embed></object>'; } add_shortcode("youtube", "cwc_youtube");

এবার এভাবে কাজ করুন

[youtube value="http://www.youtube.com/watch?v=1aBSPn2P9bg"]

১৭।প্লাগিন ছাড়াই পোস্ট ভিউ দেখুন

এটি function.php তে লিখুন

<?php
// function to display number of posts.
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 View";
}
return $count.' Views';
}

// function to count views.
function setPostViews($postID) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}

// Add it to a column in WP-Admin
add_filter('manage_posts_columns', 'posts_column_views');
add_action('manage_posts_custom_column', 'posts_custom_column_views',5,2);
function posts_column_views($defaults){
$defaults['post_views'] = __('Views');
return $defaults;
}
function posts_custom_column_views($column_name, $id){
if($column_name === 'post_views'){
echo getPostViews(get_the_ID());
}
}
?>

এবার এটি single.php তে লিখুন,

<?php setPostViews(get_the_ID()); ?>

এবার আপনি যেখানে আপনি দেখাতে চানসেখানে লিখুন

<?php echo getPostViews(get_the_ID()); ?>

১৮। ওয়ার্ডপ্রেস আপডেট বন্ধ করুন

এটি function.php তে লিখুন

<?php
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
?>

১৯। আপনার প্রতিটি পোস্টে অটোমেটিকভাবে টুইটার আর ফেইসবুক বাটন যোগ করুন

নিচের কোডটি function.php তে লিখুন

function share_this($content){ if(!is_feed() && !is_home()) { $content .= '<div> <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal">Tweet</a> <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> <div> <iframe src="http://www.facebook.com/plugins/like.php?href='. urlencode(get_permalink($post->ID)) .'&amp;layout=button_count&amp;show_faces=false&amp;width=200&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:200px; height:21px;" allowTransparency="true"></iframe> </div> </div>'; } return $content; } add_action('the_content', 'share_this');

২০।কাস্টম ইউডজেট তৈরী করুন

নিচের কোড function.php তে লিখুন

Class My_Widget extends WP_Widget { function My_Widget() { parent::WP_Widget(false, 'Our Test Widget'); } function form($instance) { // outputs the options form on admin } function update($new_instance, $old_instance) { // processes widget options to be saved return $new_instance; } function widget($args, $instance) { // outputs the content of the widget } } register_widget('My_Widget')

আজ আর দিতে পার নাই,আরো নতুন নতুন এবং ছোট ছোট কোড দিয়ে আপনার সাইট সাজিয়ে দিতে আমি লিখে যাবো।

আমার সাথে ওয়ার্ডপ্রেস এর যে কোন সমস্যা নিয়ে আলাপ করতে পারেন,

http://bdweblab.com/about-us

Level 0

আমি সিএক্স রানা। বিশ্বের সর্ববৃহৎ বিজ্ঞান ও প্রযুক্তির সৌশল নেটওয়ার্ক - টেকটিউনস এ আমি 14 বছর যাবৎ যুক্ত আছি। টেকটিউনস আমি এ পর্যন্ত 24 টি টিউন ও 131 টি টিউমেন্ট করেছি। টেকটিউনসে আমার 12 ফলোয়ার আছে এবং আমি টেকটিউনসে 0 টিউনারকে ফলো করি।

WordPress Developer, Visual Composer and Recurring Payments Expert.


টিউনস


আরও টিউনস


টিউনারের আরও টিউনস


টিউমেন্টস

রানা চালিয়ে যান খুব ভালো হচ্ছে।
এবার সবাই দেখবে কথায় নয় আমরা কাজে বিশ্বাসী।

ভাল হৈছে। পিলাচ

আপনার টিউনটা দেখে ভাল লগলো।আপনি আপনার পরিচয় দিয়েছেন,আপনি পারেন।যারা পড়াশুনা করে কম্পুটার নিয়ে তাদের কাজে লাগবে।

এরকম পোস্টের ধারাবাহিক টিউন চাই। অনেক সুন্দর টিউন।

অসাধারন ।

Thank u BOSS ( RANA )+++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++

খুব সুন্দর হয়েছে।

xotil

Level 0

Nice post.
Go ahead…

Level 0

+++++++++++++++++++++++thanx

রানা ভাই অনেক অনেক সুন্দর হইছে। খুবই উপকারে লাগবে। আজকে লগ-ইন করতে ইচ্ছা করছিল না শুধুমাত্র আপনার এই টিউনটি দেখে কমেন্ট না করে থাকতে পারলাম না। এরকম আরো টিউন চাই। আপনার সাইটটিও অনেক সুন্দর ও তথ্যসমৃদ্ধ।

    Level 0

    @মাষ্টারমাইন্ড: শুনে ভালো লাগলো, আপনাদের মত ভক্তদের উপকার করতে পেরে নিজের ও ভালো লাগতেছে ।

অনেক কাজের একটা জিনিস শেয়ার করলেন।ওয়ার্ডপ্রেস নিয়ে ঘুতাচ্ছি কয়দিন ধরে।তবে নতুনদের জন্য কোনটি কোন ফাইলে কোণ জায়গায় বসানো লাগবে সেটা বললে ভালভাবে বুঝা যেত।

খুব সুন্দর এবং দরকারী পোষ্ট, যদি সম্ভব হয় ধারাবাহিক পোষ্ট করুন, ধন্যবাদ শেয়ার করার জন্য।

আমি পোস্ট টাইটেলের নিচে টিটি’র মতো মোট কতোজন পোস্টটি প্রিয়তে নিয়েছেন তা দেখাতে চাই। (যেমন আপনার পোস্টটি ২১ জন প্রিয়তে নিয়েছেন) এর জন্য কি করতে হবে যদি দয়া করে বলতেন, আমি খুব সমস্যায় আছি এটা নিয়ে। প্লিজ হেল্প করুন।

খুবই উপকারি টিউন। আমার কাজে লাগবে। আচ্ছা আমার ওয়ার্ডপ্রেস সাইটে নতুন কোনো পোষ্ট পাবলিশ হলে হোমপেজ নিজে থেকেই রিফ্রেশ হবে এরকম কিছুর জন্য কোড আছে?? অথবা কোনো প্লাগিন্সের মাধ্যমে কি কাজটি করা যায়?? দয়া করে জানালে উপকৃত হতাম। ধন্যবাদ।