بابهت: بەکارهێنانى Post Formats + هێنانى پەڕگە لە ڕووکار..
بسم الله الرحمن الرحیم
پەنا بە خودا لەم بابەتە باسى تایبەتمەندیەکى بنچینەىى ڕووکار دەکەم ئەویش بەکارهێنانى Post Formats (بە کوردى جۆرى بابەت).. ئەم تایبەتمەندیە لە وەشانى ٣.١ بۆ وۆردپرێس ناساندرا....مەبەست لێى زیادکردنى شێوازێکە بۆ بابەت بەوەى کە وینەیە, میوسیکە, ویدیۆیە, ووتەیە یان هەرشتێکى تر ... ئاسایىى چەند دانەیەکى هەیە لەم وێنەیەى خوارەوەدا دیارە..
ئەوەانەى سەرەوە ئەکەوێتە سەر ئارەزووزى تۆ کە کامیان بەکاربهێنى... بۆ زیادکردنى شوێنى بابەت نووسین و شوێنى دروستکردنى پەڕە ئەوا لە ڕیگاى ئەم چەند دانە کۆدەى خوارەوە کە بۆ پەڕگەى (functions.php) زیاد ئەکەى .. تکایە لەسەرەتاى پەڕکە زیادیان بکە
// add post-formats to post_type 'post'
add_theme_support('post-formats',array('aside','gallery','link','image','quote','status','video','audio','chat'));
// add post-formats to post_type 'page'
add_post_type_support( 'page', 'post-formats' );کامیانت ویست لە (array) بیهێڵەوە... زنیارى لەسەر ئەو جۆرانەى هەن ... پیویست ناکات بکرێن بە کوردى وەک مانگى ڕۆشن مانایان دیارە
...
aside - Typically styled without a title. Similar to a Facebook note update.
gallery - A gallery of images. Post will likely contain a gallery shortcode and will have image attachments.
link - A link to another site. Themes may wish to use the first <a href=””> tag in the post content as the external link for that post. An alternative approach could be if the post consists only of a URL, then that will be the URL and the title (post_title) will be the name attached to the anchor for it.
image - A single image. The first <img /> tag in the post could be considered the image. Alternatively, if the post consists only of a URL, that will be the image URL and the title of the post (post_title) will be the title attribute for the image.
quote - A quotation. Probably will contain a blockquote holding the quote content. Alternatively, the quote may be just the content, with the source/author being the title.
status - A short status update, similar to a Twitter status update.
video - A single video. The first <video /> tag or object/embed in the post content could be considered the video. Alternatively, if the post consists only of a URL, that will be the video URL. May also contain the video as an attachment to the post, if video support is enabled on the blog (like via a plugin).
audio - An audio file. Could be used for Podcasting.
chat - A chat transcript, like so:بەکارهێنان :
بەکارهێنانى چەند شیوەیەک دەگرێتەوە کە ..
یەکەمیان : ئەتوانیت واى لێبکەیت وەک ئەوەى لە ڕووکارى Twenty Twelve ـى سەرەکى هەیە کە لە پەڕەى سەرەتا دا سوودى لە جۆرى بابەتەکان بینوە بە جۆریک بۆ هەریەێکیان بەشێوەیەک ڕیکخستنى بۆ کردووە.. واتە ئەو بابەتى کە جۆرەکەى image بەشێوەیەک دەردەکەوێ وە جۆرەکانى تریش هەر یەکە و بە جۆرێکى تر.... بۆ سوود بین لەو جۆرە ئیمە کار لەگەڵ Loop ـى سەرەکى ئەکەین کە بۆ بانگکردنى بابەتەکان فەنکشنى get_template_part بەکار ئەهێنین... دواتر زانیارى تەواو لەسەر ئەو ئەدەم... ئەمەى خوارەوە شێوەیەکە لە Loop ـى پەڕەى سەرەتا کە جۆرى جیاوازى بابەتەکانى لێ بانگراوە... ئێستا لەو چەند دێرە کۆدە ناگەیت تا لەسەر فەنکشنى get_template_part نە خوێنیتەوە...
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php endif; // end have_posts() check ?>تێبینى // ئێستا لیرە ئەوە دەخەمەڕوو هەرچەندە کە پەیوەندى بە فەنکشنى get_template_part ... دواى ئەوەى کە کۆدەکەى سەرەوەت بەکارهێنا ئەبێت ئەو پەڕگانە لە نیو ڕووکارەکەت هەبن.. لە نیو هەریەکەشیان کۆدى پێویست نووسرابێت...
content.php
content-image.php
content-aside.php
content-{other types...}.phpدووەمیان : بەکارهێنانیەتى لە نێو بابەت یان پەڕە هەردووکى بەیەک شێوە ئەکرێ ئەڵبەتە لیرەش هەر کار لەگەڵ Loop ـى سەرەکى ئەکەین .. دیسانەوە هەمان بیرۆکەى خاڵى یەکەمە تەنیا ئەوەندەیە کارەکان لە نێو پەڕگەى single.php ـە..
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'incontent', get_post_format() ); ?>
<?php endwhile; ?>
<?php endif; // end have_posts() check ?>هەمان تێبینى خاڵى یەکەم ...
incontent.php
incontent-image.php
incontent-aside.php
incontent-{other types...}.phpسیێەم :ئەوەیە کە ناتەوێ هیچ کام لەوانەى سەرەوە بەکاربێنى واتە لە برى ئەوان تەنیا لەسەرەتا یان لە نێو بایەت یان لە نێو پەڕە بەجیا بەکاریان بهێنى... ئەویش لە ڕیگەى if ـێکەوەیە کە ئەمەیە
if( has_post_format('image') ):
// do something
elseif( has_post_format('aside') ):
//do some thing
endif;--------------------------------------------
هێنانى پەڕگە لەڕووکار Get Template Part
ئەمە فەنکشنێکى ۆردپرێس کە تایبەتە بە هێنانى پەڕگەلە نیو ڕووکاردا ... ئەمە لە برى شێوازەکانى هێانانى پەڕگە بە PHP وەک include بەکاردێێت... چاکى ئەمە لەوادایە گەر پەڕگەکە بوونىشى نەبێت نابێتە هۆى دروستبوونى هەڵە وەک ئەوەى PHP ... فەنکشنەکە ئاوا ئەنووسرێ
get_template_part($slug,$name);ئەم فەنکشنە دوو پاڕامیتەرى هەیە کە بریتین لە name & slug .. سوودى هەردووکیان ئەوەیە کەبە هۆیانەوە پةرگە بانگ ئەکرێ بەجۆرێک ناوى پەڕگە واى لێدێت slug-name.php... بۆ نموونە پەڕگەیەک بەم ناوە بێت content-video.php ئاوا بانگ ئەکرێ
get_template_part('content','video');ئاسایی گەر slug نەشنووسرێ ئەوا پەڕگەکە گەر بە name ـەکە هەبێت ئەوا دەهێنێت ..واتە بەم جۆرە..
get_template_part('content');لێرە پەڕگەکە بە نێوى content.php ـەوە هەیە....
ئێستا دێنیە سەر ئەوەى کە گەر پەڕگەکە لە نێو بوخچەیەکیش هەبێت ۆن بانگى بکەین؟ ... بۆ نموونە گەر پەڕگەکە ناوى content-video.php و لە نێو بوخچەیەکیش بێت بە نێوى inc ئەوا بەم جۆە بانگى ئەکەین...
get_template_part('inc/content','video');زانیارى زۆرتر..
http://codex.wordpress.org/Post_Formats
http://codex.wordpress.org/Function_Ref … plate_part
ڕێز..
٢٠١٤/٨/٢