Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

bn:ট্যাক্সোনমি


ট্যাক্সোনমি কি?

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

উদাহরণ হিসেবে, আমার বিভিন্ন ধরনের পশু-পাখি রয়েছে। আমি সেগুলোকে বিভিন্ন আচরণ অনুযায়ী গ্রুপ করতে পারি এবং সেগুলোর একটা নাম দিতে পারি। এটা হচ্ছে এমন একটি বিষয় যা, বেশীরভাগ মানুষ জীববিজ্ঞান ক্লাসে শিখে থাকে এবং এটা Linnaean Taxonomy নামে পরিচিত।

ওয়ার্ডপ্রেসে, একটি "taxonomy" হচ্ছে কিছু পোস্টকে (বা লিঙ্ক অথবা কাস্টম পোস্ট টাইপ) দলভুক্ত করার একটি পদ্ধতি।

একটি ট্যাক্সোনমির মধ্যে আলাদা আলাদা গ্রুপের নামকরণের জন্য যেটা ব্যবহার করা হয়, তাকে বলা হয় terms. উদাহরণ হিসেবে প্রথমে যে পশু-পাখিদের গ্রুপের কথা বলা হয়েছিলো, তারমধ্যে আমরা একটির নাম দিতে পারি "birds", এবং অন্য আরেকটি "fish"। "Fish" এবং "birds" হচ্ছে আমাদের ট্যাক্সোনমির টার্মস। ওয়ার্ডপ্রেস এর উদাহরণ অনুযায়ী একটি ক্যাটাগরি বা ট্যাগ (পরবর্তী অংশ দ্রষ্টব্য) হচ্ছে টার্ম।

ট্যাক্সোনমির সাধারণ ছক এবং ওয়ার্ডপ্রেসে তাদের সম্পর্ক

Z2Ohv.png

Diagram added with no restrictions with compliments by Pieter Goosen

ডিফল্ট ট্যাক্সোনমি

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

ক্যাটাগরি

The 'category' taxonomy lets you group posts together by sorting them into various categories. These categories can then be seen on the site by using '/category/name' types of URLs. Categories tend to be pre-defined and broad ranging.

ট্যাগ

The 'post_tag' taxonomy is similar to categories, but more free form. Tags can be made up on the fly, by simply typing them in. They can be seen on the site in the '/tag/name' types of URLs. Posts tend to have numerous tags, and they are generally displayed near posts or in the form of tag clouds.

লিঙ্ক ক্যাটাগরি

The 'link_category' taxonomy lets you categorize your links. These tend to be used only internally, for organizational reasons, and are not usually exposed on the site itself. They are handy for defining groups of links to be displayed in sidebars and the like.

পোস্ট ফরম্যাট

The 'post_format' taxonomy was introduced in Wordpress 3.1 and is is a piece of meta information that can be used by a theme to customize its presentation of a post. New post formats can't be created or added to the default existing ones

কাস্টম ট্যাক্সোনমি

Since WordPress 2.3, you've been able to create your own custom taxonomies, but these have been a rarely used feature of WordPress until Version 2.9. In truth, they are an extremely powerful way to group various items in all sorts of ways.

উদাহরণ

The plugin Matt's Community Tags uses taxonomies to define "people" as a taxonomy for attachments. He uses it to allow people to mark the names of people in pictures, and using that his site can display pictures of people under the '/person/name' URL.

ট্যাক্সোনমি রেজিস্টার

To register a taxonomy, you use the register_taxonomy() function.

Here's an example of registering a "people" taxonomy:

function people_init() {
	// create a new taxonomy
	register_taxonomy(
		'people',
		'post',
		array(
			'label' => __( 'People' ),
			'rewrite' => array( 'slug' => 'person' ),
			'capabilities' => array(
				'assign_terms' => 'edit_guides',
				'edit_terms' => 'publish_guides'
			)
		)
	);
}
add_action( 'init', 'people_init' );

Here, the "people" taxonomy is defined. It's defined to work for posts, and a rewrite slug is defined to make the url into '/person/' instead of '/people/'. The capabilities line is optional. Without it, WordPress will default capabilities to the same users as posts. As shown above, this will allow any user with the custom "edit_guides" capability to assign the taxonomy to a post and any user with the custom "publish_guides" capability to create new taxonomy items.

Taxonomy capabilities include assign_terms, edit_terms, manage_terms (displays the taxonomy in the admin navigation) and delete_terms.

ট্যাক্সোনমি ব্যবহার

Once you've added a taxonomy, you'll find that WordPress creates a new meta box on posts for you. This new meta box looks almost exactly like the Tags box and will let you add tags to those posts.

If you're not attaching your taxonomy to posts, then you may not get the interface created for you. Taxonomies are generic, after all, you could create one for any sort of object. To add terms to an object using your taxonomy, you'll need to use the wp_set_object_terms() function. Here's an example of adding the term "Bob" to post ID number 123 in the "person" taxonomy:

wp_set_object_terms( 123, 'Bob', 'person' );

As you can see, it's simple to do. The second parameter can also be an array of terms to add all at once, if you need to do so.

ক্লাউড

The wp_tag_cloud() function can also accept a "taxonomy" parameter, if you want to display a cloud of terms for your custom taxonomy.

টার্ম তালিকাভুক্ত করা

If you want to have a custom list in your theme, then you can pass the taxonomy name into the the_terms() function in the Loop, like so:

the_terms( $post->ID, 'people', 'People: ', ', ', ' ' );

That displays the list of People attached to each post.

ট্যাক্সোনমির ভিত্তিতে কুয়েরি

Creating a taxonomy generally automatically creates a special query variable using WP_Query class, which we can use to retrieve posts based on. For example, to pull a list of posts that have "Bob" as a "person" taxonomy in them, we will use:

$query = new WP_Query( array( 'person' => 'bob' ) );

or, for more complex argument:

$args = array(
	'tax_query' => array(
		array(
			'taxonomy' => 'person',
			'field' => 'slug',
			'terms' => 'bob'
		)
	)
);
$query = new WP_Query( $args );

404 নং ত্রুটি

If your site uses custom permalinks, you will need to flush your permalink structure after making changes to your taxonomies, or else you may see a "Page Not Found" error. Your permalink structure is automatically flushed when you visit Settings > Permalinks in your WordPress dashboard.

প্রাসঙ্গিক

See also index of Function Reference and index of Template Tags.

বাহ্যিক উৎস সমূহ