السلام عليكم ورحمة الله وبركاته
في هذه التدوينة سنتحدث عن طريقة انشاء قالب لصفحة الأرشيف والتي تسهل على زوار المدونة تصفح التدوينات
اول شيئ نفتح ملف جديد باسم archives.php وقم التحقق من مجلد القالب اذا كان يحتوي على ملف بنفس الاسم واذا وجدت ملف بهذا الاسم قم بتسميته archive-page.php
نفتح الملف باي محرر مثل notepad + او editplus نضيف اسم قالب الصفحة لكي يتعرف الووردبريس على الصفحة الجديدة
<?php
/*
Template Name: archives
*/
?>
class=”brush:html”>لكي يكتمل الشرح ضروري نشتغل على قالب اخترت هذا القالب Cyangant الان قم بفتح ملف نماذج الصفحات (page.php) وانسخ الكود كامل وقم بلصقه في الملف الذي قمنا بانشائه ولا تنسى تحويل ترميز الملف الى UTF-8 لكي تظهر الحروف العربية بشكل سليم وهكذا يصبح الكود :
<?php
/*
Template Name: archives
*/
?>
<?php get_header(); ?>
<div id="content">
<?php breadcrumbs(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<div class="post-text"><h2 class="post-title"><?php the_title(); ?></h2></div>
<?php the_content(´<p class="serif">Read the rest of this page »</p>´); ?>
<?php wp_link_pages(array(´before´ => ´<p><strong>Pages:</strong> ´, ´after´ => ´</p>´, ´next_or_number´ => ´number´)); ?>
<?php edit_post_link(´<span class="entry-edit">تحرير هذه التدوينة</span>´); ?>
<?php endwhile; endif; ?>
<p class="post-share">
<strong>إذا اعجبتك التدوينة ، فلا تنسى مشاركتها مع اصدقائك : </strong>
<a href="http://digg.com/submit?phase=2&url=<?php the_permalink(); ?>" class="digg" title="Digg it"></a>
<a href="http://www.stumbleupon.com/submit?url=<?php the_permalink(); ?>&title=<?php echo urlencode(get_the_title($id)); ?>" title="StumbleUpon" class="stumbleupon"></a>
<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php echo urlencode(get_the_title($id)); ?>" title="Facebook" class="facebook"></a>
<a href="http://twitter.com/home?status=<?php echo urlencode("Currently reading: "); ?><?php the_permalink(); ?>" title="Twitter" class="twitter"></a>
<a href="http://delicious.com/post?url=<?php the_permalink(); ?>&title=<?php echo urlencode(get_the_title($id)); ?>" title="del.icio.us" class="delicious"></a>
<a href="http://www.google.com/bookmarks/mark?op=add&bkmk=<?php the_permalink();?>title=<?php echo urlencode(get_the_title($id)); ?>" title="Google" class="google"></a>
<a href="http://bookmarks.yahoo.com/toolbar/savebm?u=<?php the_permalink(); ?>&t=<?php echo urlencode(get_the_title($id)); ?>" title="Yahoo!" class="yahoo"></a>
<a href="http://reddit.com/submit?url=<?php the_permalink(); ?>&title=<?php echo urlencode(get_the_title($id)); ?>" title="Reddit" class="reddit"></a>
</p>
</div><!-- END Post -->
</div><!-- END Content -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
الان قم بحذف الكود التالي :
<?php the_content(´<p class="serif">Read the rest of this page »</p>´); ?>
class=”brush:html”>او
class=”brush:html”><?php the_content(); ?>
class=”brush:html”>على حسب القالب الذي تشتغل عليه وضع مكانه الكود التالي :
class=”brush:html”><?php
$previous_year = $year = 0;
$previous_month = $month = 0;
$ul_open = false;
$myposts = get_posts(´numberposts=-1&orderby=post_date&order=DESC´);
?>
<?php foreach($myposts as $post) : ?>
<?php
setup_postdata($post);
$year = mysql2date(´Y´, $post->post_date);
$month = mysql2date(´n´, $post->post_date);
$day = mysql2date(´j´, $post->post_date);
?>
<?php if($year != $previous_year ¦¦ $month != $previous_month) : ?>
<?php if($ul_open == true) : ?>
</ul>
<?php endif; ?>
<h3><?php the_time(´F Y´); ?></h3>
<ul>
<?php $ul_open = true; ?>
<?php endif; ?>
<?php $previous_year = $year; $previous_month = $month; ?>
<li><span><?php the_time(´j F´); ?> – </span> <span><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></span></li>
<?php endforeach; ?>
</ul>
الان يصبح الكود كاملا على الشكل التالي :
<?php
/*
Template Name: archives
*/
?>
<?php get_header(); ?>
<div id="content">
<?php breadcrumbs(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<div class="post-text"><h2 class="post-title"><?php the_title(); ?></h2></div>
<?php
$previous_year = $year = 0;
$previous_month = $month = 0;
$ul_open = false;
$myposts = get_posts(´numberposts=-1&orderby=post_date&order=DESC´);
?>
<?php foreach($myposts as $post) : ?>
<?php
setup_postdata($post);
$year = mysql2date(´Y´, $post->post_date);
$month = mysql2date(´n´, $post->post_date);
$day = mysql2date(´j´, $post->post_date);
?>
<?php if($year != $previous_year ¦¦ $month != $previous_month) : ?>
<?php if($ul_open == true) : ?>
</ul>
<?php endif; ?>
<h3><?php the_time(´F Y´); ?></h3>
<ul>
<?php $ul_open = true; ?>
<?php endif; ?>
<?php $previous_year = $year; $previous_month = $month; ?>
<li><span><?php the_time(´j F´); ?> - </span> <span><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span></li>
<?php endforeach; ?>
</ul>
<?php wp_link_pages(array(´before´ => ´<p><strong>Pages:</strong> ´, ´after´ => ´</p>´, ´next_or_number´ => ´number´)); ?>
<?php edit_post_link(´<span class="entry-edit">تحرير هذه التدوينة</span>´); ?>
<?php endwhile; endif; ?>
<p class="post-share">
<strong>إذا اعجبتك التدوينة ، فلا تنسى مشاركتها مع اصدقائك : </strong>
<a href="http://digg.com/submit?phase=2&url=<?php the_permalink(); ?>" class="digg" title="Digg it"></a>
<a href="http://www.stumbleupon.com/submit?url=<?php the_permalink(); ?>&title=<?php echo urlencode(get_the_title($id)); ?>" title="StumbleUpon" class="stumbleupon"></a>
<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php echo urlencode(get_the_title($id)); ?>" title="Facebook" class="facebook"></a>
<a href="http://twitter.com/home?status=<?php echo urlencode("Currently reading: "); ?><?php the_permalink(); ?>" title="Twitter" class="twitter"></a>
<a href="http://delicious.com/post?url=<?php the_permalink(); ?>&title=<?php echo urlencode(get_the_title($id)); ?>" title="del.icio.us" class="delicious"></a>
<a href="http://www.google.com/bookmarks/mark?op=add&bkmk=<?php the_permalink();?>title=<?php echo urlencode(get_the_title($id)); ?>" title="Google" class="google"></a>
<a href="http://bookmarks.yahoo.com/toolbar/savebm?u=<?php the_permalink(); ?>&t=<?php echo urlencode(get_the_title($id)); ?>" title="Yahoo!" class="yahoo"></a>
<a href="http://reddit.com/submit?url=<?php the_permalink(); ?>&title=<?php echo urlencode(get_the_title($id)); ?>" title="Reddit" class="reddit"></a>
</p>
</div><!-- END Post -->
</div><!-- END Content -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
قم بحفظ الكود وارفعه الى مجلد القالب الذي تشتغل عليه ولا تنسى ان تتحقق من عدم وجود ملف له نفس اسم الملف الذي سترفعه
الان نتوجه الى لوحة التحكم لإضافة صفحة جديدة :
الان من خصائص الصفحة في القائمة الجانبية من لوحة التحكم على يسارك اختر اسم قالب الافتراضي لصفحة
قم بنشر الصفحة وتصفح الارشيف الجديد ومبروك عليك الارشيف وهذا مثال على صفحة الارشيف بالنسبة للقالب الذي نشتغل عليه
كما تلاحظ في المثال يجب حذف الأشياء مثل حرر هذه التدوينة وا اذا اعجبتك هذه التدوينة مع كثرة الشروحات سوف تتحترف تعديل القوالب
لتحميل الاكواد المستعملة في الشرح من هنا
الى هنا نكن قد انتهينا من طريقة انشاء صفحة الأرشيف للووردبريس والى اللقاء في تدوينة جديدة انشاء الله
اذا كان هناك اي استفسار يرجى وضع تعليق
والسلام عليكم ورحمة الله وبركاته
الاكاديمية العربية لفنون التصميم و الجرافيك
يجب عليك تسجيل الدخول لكتابة تعليق.