March 15, 2009Leave a Comment

If u are reached here using search engine then I am sure that you are just fucked up :( .. is_home(), is_single(), is_category() are not working…specially in footer and other places. I faced the same problem. While working with a wordpress theme, this functions were working fine in footer but once I noticed that they are not working as they should be !….

Let me explain why and how this problem occurs and what’s the solution :

I think if u are familiar with the famus LOOP in wordpress. The following is_home(), is_single(), is_category() functions depends on the loop. ACtually when u visit the home page then header.php, index.php, sidebar.php and footer.php files are executed and in the same way when u visit a single post then normally header.php, single.php, sidebar.php and footer.php files are executed. Actually some global page specific query is done for single.php, index.php etc. is_home(), is_single(), is_category() they will work fine if u use the default theme and don’t add any custom query !

Let’s check the code for is_home() function …

/**
* Whether current page view is the blog homepage.
*
* @since 1.5.0
* @uses $wp_query
*
* @return bool True if blog view homepage.
*/
function is_home () {
global $wp_query;
return $wp_query->is_home;
}

Ok, for custom query maximum time I use this function get_posts. But to get more control I used query_posts. They are same and share some common arguments but query_posts gives more controls and more arguments to pass to get the exact query. Now Let’s check the code for query_posts() function

/**
* Setup the Loop based on the query variables.
*
* @uses WP::$query_vars
* @since 2.0.0
*/
function query_posts() {
global $wp_the_query;
$this->build_query_string();
$wp_the_query->query($this->query_vars);
}

and code for get_posts

/**
* Retrieve list of latest posts or posts matching criteria.
*
* The defaults are as follows:
*     'numberposts' - Default is 5. Total number of posts to retrieve.
*     'offset' - Default is 0. See {@link WP_Query::query()} for more.
*     'category' - What category to pull the posts from.
*     'orderby' - Default is 'post_date'. How to order the posts.
*     'order' - Default is 'DESC'. The order to retrieve the posts.
*     'include' - See {@link WP_Query::query()} for more.
*     'exclude' - See {@link WP_Query::query()} for more.
*     'meta_key' - See {@link WP_Query::query()} for more.
*     'meta_value' - See {@link WP_Query::query()} for more.
*     'post_type' - Default is 'post'. Can be 'page', or 'attachment' to name a few.
*     'post_parent' - The parent of the post or post type.
*     'post_status' - Default is 'published'. Post status to retrieve.
*
* @since 1.2.0
* @uses $wpdb
* @uses WP_Query::query() See for more default arguments and information.
* @link http://codex.wordpress.org/Template_Tags/get_posts
*
* @param array $args Optional. Override defaults.
* @return array List of posts.
*/
function get_posts($args = null) {
$defaults = array(
'numberposts' => 5, 'offset' => 0,
'category' => 0, 'orderby' => 'post_date',
'order' => 'DESC', 'include' => '',
'exclude' => '', 'meta_key' => '',
'meta_value' =>'', 'post_type' => 'post',
'suppress_filters' => true
);

$r = wp_parse_args( $args, $defaults );
if ( empty( $r['post_status'] ) )
$r['post_status'] = ( 'attachment' == $r['post_type'] ) ? 'inherit' : 'publish';
if ( ! empty($r['numberposts']) )
$r['posts_per_page'] = $r['numberposts'];
if ( ! empty($r['category']) )
$r['cat'] = $r['category'];
if ( ! empty($r['include']) ) {
$incposts = preg_split('/[\s,]+/',$r['include']);
$r['posts_per_page'] = count($incposts);  // only the number of posts included
$r['post__in'] = $incposts;
} elseif ( ! empty($r['exclude']) )
$r['post__not_in'] = preg_split('/[\s,]+/',$r['exclude']);

$r['caller_get_posts'] = true;

$get_posts = new WP_Query;
return $get_posts->query($r);

}

get_posts will not make any problem for is_single(), is_home(), is_category() etc functions.

Solution: To avoid this problem you can use this trick:

$query_backup = clone($GLOBALS['wp_query']); //keep backup
......
query_posts(.....)
...
$GLOBALS['wp_query'] = $query_backup; //restore from backup

Further info: Please keep in mind that the php function clone() will not work in php4, it’s just for php5 becuase Php5 handles objects in different way. Like in php5 you can copy a object in this way
$new_object = clone ($old_object);
here $new_object will not copy the object actually though it will just point to $old_object but in php4 the thing is just copy like bellow.
$new_object = $old_object;

You can check this link for better explanation.

Sometimes pain gives us a way to think :P

thanks

মার্চ ১৩, ২০০৯মন্তব্য করুন

[যদি আপনার নরমাল এইটিএমএল এবং একদম বেসিক পিএইচপি জ্ঞান না থাকে তাহলে এই পোস্টের কিছু বিষয় জটিল মনে হতে পারে ]
অনেকেই ব্যক্তিগত হোস্টিং এ ওয়ার্ড প্রেস ইনস্টল করে ব্লগিং করছেন এবং পছন্দের কোন ফ্রি থীম ইনস্টল করে দিব্যি সুন্দর ব্যক্তিগত ব্লগ বানিয়ে নিচ্ছেন। যদি এমন হয় এই থীম কিভাবে কাজ করে তা যদি জানা থাকে তাহলে আরো মজা না ? ইচ্ছা হলো একটু সম্পাদনা করে থীমটাকে নিজের মতো সাজিয়ে নিলেন। আমার বকবক শুরুর আগে আসুন জেনে নেই এই পোস্টের উদ্দেশ্যগুলোঃ

একঃ ওয়ার্ড প্রেসের থীম কিভাবে কাজ করে
দুইঃ থীম ফোল্ডারের কোন ফাইলের কাজ কি
তিনঃ থীম সম্পাদনা করা
চারঃ ইত্যাদি :ttt:
…continue reading ওয়ার্ড প্রেসের থীম কিভাবে কাজ করে-পর্ব-১

মার্চ ১২, ২০০৯মন্তব্য করুন

ধরুন আপনার ওয়ার্ড প্রেস ব্লগের(সেলফ হোস্টেড) লিঙ্ক যদি হয় http://www.mysite.com তাহলে আপনার এডমিন প্যানেলে ঢুকার লিঙ্ক হবে এই রকমঃ http://www.mysite.com/wp-admin । এই পাতায় গেলেই বিশাল একটা ওয়ার্ড প্রেসের ছবি। আপনি চাইলেই কিন্তু এই ছবি, ছবির উপর মাউস নিলে যে টুপ টিপ/টাইটেল(powered by wordpress ) দেখায় এবং ছবিটার লিঙ্ক (ডিফল্ট ওয়ার্ড প্রেস সাইটের লিঙ্ক থাকে) ইত্যাদি পরিবর্তন করে সম্পূর্ণ নিজের মতো করে নিতে পারেন।

এর জন্য প্লাগিন পাওয়া যায় কিন্তু যদি নিজেই শিখে ফেলেন কিভাবে কাজটা করতে হবে তাহলে মজাটা বেশি… তাই না ? আর হ্যাঁ এই ধরনের পরিবর্তন ওয়ার্ড প্রেস সাপোর্ট করে বলেই কোর ফাইলের কোন ধরনের পরিবর্তন না করে আপানাকে প্লাগিন দিয়ে বা থীম থেকে হুক করার মাধ্যমে নিজের ইচ্ছামত কিছু বসিয়ে দেওয়ার সুযোগ রেখেছে। :C
…continue reading ওয়ার্ড প্রেসে এডমিন লগিন পেজকে পরিবর্তন করুন নিজের মতো করে

মার্চ ৬, ২০০৯মন্তব্য করুন

rss icons collection by cadenhead 150x150 আমাদেরপ্রযুক্তি ফোরাম নির্দিষ্ট কোন ফোরামের লেটেস্ট পোস্টের আর.এস.এস  ফীডতথ্যের সহজ আদান প্রদানের অন্যতম মাধ্যম হলো আর.এস.এস. ফীড । পিএইচপিবিবি৩ এর সাথে ডিফল্ট কোন আর.এস.এস. ফীড অপশন না থাকায় একদম প্রথম দিকে একটি ছোট মড (মডিফিকেশন) বানিয়েছিলাম আর.এস.এস. ফীডের জন্য (মূল পিএইচপিবিবি সাইটে এখানে মডটি পাওয়া যাবে যদিও সময়ের অভাবে ঐখানে আর অনেক দিন আপডেট করি নাই।)। আমাদের প্রযুক্তি সর্বশেষ পোস্টের জন্য আর.এস.এস. ফীডের লিঙ্ক ফোরামের একদম উপরের দিকে ডান পাশে পাবেন। …continue reading আমাদেরপ্রযুক্তি ফোরাম-নির্দিষ্ট কোন ফোরামের লেটেস্ট পোস্টের আর.এস.এস ফীড

মার্চ ৫, ২০০৯মন্তব্য করুন

ওয়ার্ডপ্রেসে একটা সুবিধা আছে যে আপনি যতবার কোন পোস্ট সম্পাদনা করবেন তত বার পোস্ট টেবিলে নতুন একটা row তৈরি করবে মানে আপনার প্রতিবারের পরিবর্তন গুলো ঠিক ঠাক মতো আলাদা আলাদা পোস্ট হিসাবে সংরক্ষণ করবে। যারা ওয়ার্ডপ্রেস ব্লগ ব্যবহার করেন তারা যদি একটু খেয়াল করেন তাহলে দেখবেন পোস্ট সম্পাদনা করতে গেলে নিচের দিকে “Post Revisions” নামে একটা ব্লক পাবেন। এটা বেশ সুবিধার কারণ আপনি চাইলে আপনার আগের কোন রিভিশনের রোল ব্যাক করতে পারেন। হয়তো ভুল করে কোন সম্পাদনা করলেন আবার আগের অবস্থায় ফিরে আসলেন। এর অসুবিধাও আছে যেমন, পোস্ট সংখ্যার বাড়ার সাথে সাথে এই রকম অসংখ্য রিভিশন ডাটাবেজে সেইভ হবে। উল্লেখ্য যে প্রতি রিভিশনের পোস্টের সাথে সংশ্লিষ্ট সব কিছু সংরক্ষণ হয়। তাই যাদের ডাটাবেজ সাইজের লিমিটেশন রয়েছে তারা চাইলে এই রিভিশন করার ব্যবস্থা/অপশন বন্ধ করে দিতে পারেন। …continue reading ওয়ার্ডপ্রেসে পোস্ট রিভিশন বন্ধ করুন

February 24, 20097 Comments

….no I will not write…I will break the chain….etc….I was not in me that day… Hasin vai said,”…grrr….”. ….Now feeling cool and….Ok here something about me but I will not tag any one …mu ha ha.

  • I am little bit crazy type from my childhood.
  • I don’t smoke ..I mean the nasty cigs.
  • I like ice-cream and to walk alone.
  • I am honest with myself and I like to say what I believe.
  • I am workholic and fun loving. I have passed so many hrs with depression and hope to pass in future. I like to live and reborn. I like to start again when I loose all hope :) . That’s the manchumahara in me.
  • Sometimes I watch porn/adult movies to retrieve concentration.
  • I think, I feel some one specially.

These are discrete random 7 things about me.

জানুয়ারী ৩১, ২০০৯মন্তব্য করুন

প্রতিদিন কোন না কোন সমস্যার সম্মূখীন হচ্ছি আর একটু গুগল করেই তার সমাধান পেয়ে যাচ্ছি। ওয়েবে ম্যাথমেটিক্যাল ইকুয়েশন প্রকাশ করার জন্য একটা ভালো পিএইচপির লাইব্রেরী পেয়েছিলাম অনেক দিন আগে। নামে PhpMathPublisher। এটি চাইলে যে কেউ তার নিজের সাইটে যুক্ত করতে পারেন। কার্যক্রমটা এই রকম, আপনি একটা নির্দিষ্ট ফরম্যাটে লিখবেন। যেমন ধরুন a+b = d যা পরে এক বা একাধিক ইমেজ আকারে কোন ডিরেক্টরীতে সংরক্ষিত হবে। অনলাইন ডেমো দেখতে পারেন এখান থেকে। এছাড়া এই লাইব্রেরীটি যে সব ম্যাথেমেটিক্যাল কমান্ড (ইকুয়েশন লেখার জন্য, কনসেপ্ট অনেকটা লেটেক্স এর মতো) সাপোর্ট করে তার লিস্ট এখানে পাবেন।

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

জানুয়ারী ৩০, ২০০৯মন্তব্য করুন

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

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

January 11, 20095 Comments

For somedays I was thinking to make a new wordpress theme for my own blog and  I did at last. My new theme is live now though it’s not completed yet but working fine. I gave my theme name “Chitra2009″ as the name of river Chitra . I like my theme and hope u will like this. The theme is little bit special as it loads faster and ajax based. Max widgets are ajaxified and the theme specially supports some popular plugins. I have used jQuery as js library and for ajax works. I got the design concept from  jquery.com and prothom-aloblog.com.

Still I need to do many thing. BTW, there is a special feature for bengali community as the theme can be used for bangla unicode blog too (But for personal blog, I didn’t think multi user blog). As bengali fonts are small , there is a option to write bangla and english in same post with same font size in frontend with a special tag. Even the whole post can be mark as bangla so that the title and post text every things is shown in large bangla font.

I want to make this theme free for all and it will be released under GPL or some thing like that at the end of feb,2009. I want your kind feedback to improve it.

Thanks,
Manchumahara

ডিসেম্বর ১৮, ২০০৮১টি মন্তব্য

নোটঃ এই পোস্ট ওয়ার্ড প্রেস ২.৭ এর জন্য লেখা তবে ২.৬.x এ কাজ করবে।
চাইলে ওয়ার্ডপ্রেসকে কোন সিএমএস(ওয়ার্ড প্রেস একটা সিএমএস ই তবে তা ব্লগের জন্য বিশেষ ভাবে তৈরি) মতো ব্যবহার করা যায়। ধরুন আপনি আলাদা একটা পেজ তৈরি করতে চান যেখানে ইচ্ছা মতো কোয়ারী করে ডাটা শো করবেন। কাজটা কিভাবে করা যেতে পারে তা নিয়েই আলোচনা করতে চাইছি।

প্রথমে আপনার থীমে ফোল্ডারে একটা নতুন ফাইল যুক্ত করতে হবে। ধরুন blog.php. এখন ফাইলটা ওপেন করুন আর প্রথমেই লিখুন
/*
Template Name: Blog Template
*/

Template Name: Blog Template এই লাইন এর অর্থ হলো এই টেমপ্লেট ফাইলটা কোন বিশেষ পেজের জন্য ব্যবহার করা যেতে পারে। ডিফল্ট কোন পেজে (ওয়ার্ড প্রেসের এডমিন প্যানেল থেকে যে পেজ তৈরি করা যায়) দেখানোর জন্য থীমের page.php ফাইল ব্যবহার করা হয়। যদি আপনার থীম ফোল্ডারের ভেতর এমন কোন ফাইল থাকে যার শুরুতে উপরের মতো কোড লেখা থাকে তাহলে সেটা কোন কোন পেজের জন্য টেমপ্লেট ফাইল হিসাবে আপনি সিলেক্ট করতে পারবেন।
…continue reading ওয়ার্ডপ্রেসে কোন পেজের জন্য কাস্টম টেমপ্লেট ফাইল

feedback