Friday, October 13, 2017

ওয়ার্ডপ্রেস থিম কাস্টমাইজেশন পর্ব-৭, ওয়ার্ডপ্রেস সাইটের জন্য সাইটম্যাপ তৈরী করুন কোন রকম প্লাগিন ছাড়া। সহজেই!

সাইটম্যাপ হল যে কোন সাইট/ওয়েবসাইটের একটা গুরুত্বপূর্ণ বিষয়। এই সাইটম্যাপের মাধ্যমে সকল পোষ্ট বা পেজকে এক জায়গায় আনা ও একবারে বিভিন্ন ভিজিটর বা সার্চ ইঞ্জিনে সাবমিট করা যায়। ফলে আমাদের কষ্ট অনেকাংশে কমে যায়। ওয়ার্ডপ্রেস সাইটে সাইটম্যাপ যুক্ত করার জন্য বিভিন্ন রকম প্লাগিন আছে যার মাধ্যমে আপনি আপনার ওয়ার্ডপ্রেস সাইটে সাইটম্যাপ যোগ করতে পারবেন কিন্তু আমি আজ দেখাবো কিভাবে আপনার ওয়ার্ডপ্রেস সাইটে সাইটম্যাপ যোগ করবেন কোন রকম প্লাগিন ছাড়া। এর জন্য আপনাকে প্রথমে নিচ থেকে কোড টুকু কপি করে আপনার থিমের functions.php ফাইলে যোগ করতে হবে:
/*
Put the following code in your themes functions.php file
*/
function get_html_sitemap( $atts ){

$return = '';
$args = array('public'=>1);

// If you would like to ignore some post types just add them to the array below
$ignoreposttypes = array('attachment');

$post_types = get_post_types( $args, 'objects' );

foreach ( $post_types as $post_type ) {
if( !in_array($post_type->name,$ignoreposttypes)){
$return .= '<h2>' . $post_type->labels->name.'</h2>';
$args = array(
'posts_per_page' => -1,
'post_type' => $post_type->name,
'post_status' => 'publish'
);
$posts_array = get_posts( $args );
$return .= '<ul>';
foreach($posts_array as $pst){
$return .= '<li><a href="'.get_permalink($pst->ID).'">'.$pst->post_title.'</a></li>';
}
$return .= '</ul>';
}
}

return $return;
}
add_shortcode( 'htmlSitemap', 'get_html_sitemap' );

এখন আপনি আপনার ওয়ার্ডপ্রেস সাইটে নতুন একটা পেজ তৈরী করুন এবং নাম দিন এবং পেজ কন্টেন্টে
 [htmlSitemap]

পেষ্ট করে সেভ করুন। এখন আপনার sitemap পেজে যেয়ে দেখুন সুন্দর একটা সাইটম্যাপ তৈরী হয়েছে।

ধন্যবাদ।


শেয়ার করুন

Author:

Etiam at libero iaculis, mollis justo non, blandit augue. Vestibulum sit amet sodales est, a lacinia ex. Suspendisse vel enim sagittis, volutpat sem eget, condimentum sem.

0 coment rios: