ওয়ার্ডপ্রেস প্রেমীদের ক্ষুধা মেটাতে ৭ টি পদ্ধতি

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

১. রিলেটেড পোস্ট

একই রকম পোস্ট তালিকার জন্য অনেকেই প্লাগইন ব্যবহার করে । আমি প্লাগইন ব্যাবহারের কিছু অসুবিধা থাকায় আমি কোড এ হাত দিতে ভয় পাই না। যারা প্লাগইন ব্যবহার না করে রিলেটেড পোস্ট পেতে চান তারা নিচের কোড টি কপি করে single.php তে যেখানে একই রকম পোস্ট দেখতে চান সেখানে পেস্ট করুন।

<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
	$tag_ids = array();
	foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;

	$args=array(
		'tag__in' => $tag_ids,
		'post__not_in' => array($post->ID),
		'showposts'=>5, // Number of related posts that will be shown.
		'caller_get_posts'=>1
	);
	$my_query = new wp_query($args);
	if( $my_query->have_posts() ) {
		echo '<h3>Related Posts</h3><ul>';
		while ($my_query->have_posts()) {
			$my_query->the_post();
		?>
			<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
		<?php
		}
		echo '</ul>';
	}
}
?>

বিস্তারিত
আরও পড়ুন: ওয়ার্ডপ্রেস প্লাগিন (wp-Monalisa) স্মাইলি যুক্ত করা

২.র‍েনডম পোস্ট:

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


function gte_random_posts (){
global $wpdb, $post;
$current_title = get_the_title();
$randompostthis = $wpdb->get_results("SELECT $wpdb->posts.ID, post_title, post_name, post_date, post_type, post_status FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND post_title != '$current_title' ORDER BY RAND() limit 3");
foreach ($randompostthis as $post) {
$thumb = get_post_meta($post->ID, 'Thumbnail', $single = true);
echo "<li>&nbsp;&nbsp; <img src=$thumb height=30 width=60>";
$post_title = htmlspecialchars(stripslashes($post->post_title));
echo "&nbsp;&nbsp;<a href=\"".get_permalink()."\">$post_title</a><?php the_title2('', '..', true, '150') ?></li>";
}
}


function.php তে ফাংশনটি যুক্ত করে পরে যেখানে প্রয়োজন সেখানে কল করবেন এভাবে

<?php gte_random_posts (); ?>

আরও পড়ুন: পর্ব-১: ওয়ার্ডপ্রেস দিয়ে বাংলা ভাষার ওয়েবসাইট বানানোর পদ্ধতি

৩. ১,২,৩ আকারে নেভিগেশন প্রকাশ

অধিকাংশ ওয়ার্ডপ্রেস থিমেই পৃষ্ঠার নেভিগেশন (গুগলের নেভিগেশনে মতো) সুন্দর নয়। এরকম সুন্দর করতে চাইলে নিচের ফাংশনটি থিমের function.php তে যোগ করতে হবে।


function wp_pagenavi($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) {
global $request, $posts_per_page, $wpdb, $paged;
if(empty($prelabel)) {   $prelabel = '<strong>&laquo;</strong>';
} if(empty($nxtlabel)) {
$nxtlabel = '<strong>&raquo;</strong>';
} $half_pages_to_show = round($pages_to_show/2);
if (!is_single()) {
if(!is_category()) {
preg_match('#FROM\s(.*)\sORDER BY#siU', $request, $matches);  } else {
preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);  }
$fromwhere = $matches[1];
$numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
$max_page = ceil($numposts /$posts_per_page);
if(empty($paged)) {
$paged = 1;
}
if($max_page > 1 || $always_show) {
echo "$before <div class='Nav'><span>Pages ($max_page): </span>";   if ($paged >= ($pages_to_show-1)) {
echo '<a href="'.get_pagenum_link().'">&laquo; First</a> ... ';  }
previous_posts_link($prelabel);
for($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) {   if ($i >= 1 && $i <= $max_page) {   if($i == $paged) {
echo "<strong class='on'>$i</strong>";
} else {
echo ' <a href="'.get_pagenum_link($i).'">'.$i.'</a> ';   }
}
}
next_posts_link($nxtlabel, $max_page);
if (($paged+$half_pages_to_show) < ($max_page)) {
echo ' ... <a href="'.get_pagenum_link($max_page).'">Last &raquo;</a>';   }
echo "</div> $after";
}
}
}


প্রথম পাতার নিচের (অথবা যেখানে এ নেভিগেশনটি দেখতে চান সেখানে) দিকে লিখে দিন

আরও পড়ুন: ওয়ার্ডপ্রেস প্লাগইন বানানো এত সহজ

৪.সর্বাধিক পঠিত পোস্ট:

চাইলেই আপনারনার পোস্টের কত জনা পাঠক এসেছে তা গনণা করতে পারবেন। সর্বাধিক দেখা পোস্টের তার তালিকা, মাসে বা সপ্তাহে হিসেব রাখতে পারবেন। এ জন্য টপটেন প্লাগইনটি সেটআপ করে নিন।

বাংলায় পোস্ট ও কমেন্ট লেখার ব্যবস্থা

৫. বিভাগ আরএসএস

প্রতিটি বিভাগের আরএসএস যুক্ত করুন আপনার ব্লগে। ছোট কিছু কোড লিখে index.php (অথবা category.php) তে যোগ করে দিন। কোডগুলো হলো:-


<img src="http://www.feedburner.com/fb/images/pub/feed-icon32x32.png" alt="" style="vertical-align:middle;border:0"/>
<?php
$this_category = get_category($cat);// This line just gets the active category information
print '<a href="'.get_category_feed_link($this_category->cat_ID, '').'"> বিভাগ আর এস এস</a>';
?>

৬.সর্বাধিক পোস্টকারী লেখকের তালিকা

সর্বাধিক পোস্টকারী লেখকের তালিকা, পোস্ট সংখ্যা ও তার শেষ পোস্টের শিরোনামটি আপনাকে দিবে নিচের কোড। যেখানে লেখক তালিকা দেখতে চান সেখানেই কোটটুকু যোগ করুন।

<?php
//Get users and count of posts put into array $uc, sort array by post count ascending, loop through array and echo user info, get latest post for each user and display time and title
$uc=array();
$blogusers = get_users_of_blog();
if ($blogusers) {
  foreach ($blogusers as $bloguser) {
    $post_count = get_usernumposts($bloguser->user_id);
    $uc[$bloguser->user_id]=$post_count;
  }
  arsort($uc); //use asort($uc) if ascending by post count is desired
  $maxauthor=2;
  $count=0;
  foreach ($uc as $key => $value) {
  $count++;
    if ($count <= $maxauthor) {
      $user = get_userdata($key);
      $author_posts_url = get_author_posts_url($key);
      $post_count = $value;
      echo 'User ID ' . $user->ID . ' ' . $user->user_firstname . ' ' . $user->user_lastname . ' number of posts: ' . $post_count . ' author posts url: ' . $author_posts_url .'';
      $args=array(
        'showposts'=>1,
        'author'=>$user->ID,
        'caller_get_posts'=>1
      );
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {
        while ($my_query->have_posts()) : $my_query->the_post(); ?>
          <p><small><?php the_time('m.d.y') ?></small> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
          <?php
        endwhile;
      }
    }
  }
}
?>

৭.সর্বাধিক মতামত দাতা

কে সবার্ধিক মতামত দিয়েছেন তার তালিকা, মাসিক সর্বাধিক মতামতদ্তার তালিকা পেতে এই প্লাগইনটি ব্যবহার করতে পারেন।

3 thoughts on “ওয়ার্ডপ্রেস প্রেমীদের ক্ষুধা মেটাতে ৭ টি পদ্ধতি”

  1. Pingback: বাংলা টিউটরিয়াল|বাংলা ভাষায় বিশ্বের প্রথম টিউটরিয়াল সাইট | Bangla Tutorials » Blog Archive » ওয়ার্ডপ্রেস ৩.০ এর স

Leave a Comment