منتديات رحيل لكل العرب

منتديات رحيل لكل العرب (https://r7il.com/vb/)
-   قسم تطوير المواقع ومحركات البحث والسيو Seo والووردبريس WordPress (https://r7il.com/vb/f20/)
-   -   ما هي طريقة انشاء صفحة الارشيف الكامل ووردبريس (https://r7il.com/vb/t3677/)

raheel 07-04-2019 07:23 PM

ما هي طريقة انشاء صفحة الارشيف الكامل ووردبريس
 
سنتحدث عن طريقة انشاء صفحة الارشيف الكامل لووردبريس والتي تسهل على زوار المدونة تصفح كافة المقالات هذه الصفحة مهمة لمحركات البحث في حالة كنت تهتم لتحسين موقعك فيها
هذه الطريقة تحتاج بعض المهارات في CSS و HTML في حالة ظهر الارشيف بشكل سيء لان الشرح مقتصر على تسهيل عملية عرض المقالات فقط

تحضير ملف صفحة الارشيف

اول شيئ نقوم بانشاء ملف جديد باسم archive-full.php وقم التحقق من مجلد القالب اذا كان يحتوي على ملف بنفس الاسم واذا وجدت ملف بهذا الاسم قم بتسميته archive-custom.php
نفتح الملف باي محرر مثل notepad+ او editplus نضيف اسم قالب الصفحة لكي يتعرف ووردبريس على الصفحة الجديدة







<?php /* Template Name: Full Archive */ ?>






سنحتاج نسخة من صفحة page.php للاستعانة بالبنية التي يستعملها قالبك لعرض محتوى الصفحة قم بفتح الملف وانسخ الكود بالكامل وقم باضافته الى الملف الذي قمنا بانشائها من قبل باسم archive-full.php اسفل الكود الذي الذي ذكرنا فوق ناخد على سبيل المثال قالب Twenty_Sixteen يصبح كود الصفحة بالشكل التالي :







<?php /* Template Name: Full Archive */ ?> <?php /** * The template for displaying pages * * This is the template that displays all pages by default. * Please note that this is the WordPress construct of pages and that * other "pages" on your WordPress site will use a different template. * * @package WordPress * @subpackage Twenty_Sixteen * @since Twenty Sixteen 1.0 */ get_header(); ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php // Start the loop. while ( have_posts() ) : the_post();

// Include the page content template. get_template_part( 'template-parts/content', 'page' );

// If comments are open or we have at least one comment, load up the comment template. if ( comments_open() || get_comments_number() ) { comments_template(); }

// End of the loop. endwhile; ?>

</main><!– .site-main –>

<?php get_sidebar( 'content-bottom' ); ?>

</div><!– .content-area –>

<?php get_sidebar(); ?> <?php get_footer(); ?>






عرض المقالات في صفحة الارشيف

بعد ذالك سنحتاج دوال لعرض المقالات في صفحة الارشيف لجعل الامر سهل ساستعمل (shortcode) لكي تضيف كود بسيط الى صفحة الارشيف دون الحاجة الى تعديلات كتيرة على القالب. كل ماعليك الان هو اضافة الكود ادناه الى ملف functions.php







<?php function full_archive_helper() { $previous_year = $year = 0; $previous_month = $month = 0; $ul_open = false; $myposts = get_posts('numberposts=-1&orderby=post_date&order=DESC'); foreach($myposts as $post) : setup_postdata($post); $year = mysql2date('Y', $post->post_date); $month = mysql2date('n', $post->post_date); $day = mysql2date('j', $post->post_date);
if($year != $previous_year || $month != $previous_month) :
if($ul_open == true) : echo '</ul>'; endif;
echo '<h2>'.get_the_time('F Y', $post->ID).'</h2>'; echo '<ul>';
$ul_open = true;
endif; $previous_year = $year; $previous_month = $month;
echo '<li class="hentry"> <span>'. get_the_time('j F', $post->ID).'</span> – <a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a> </li>';
endforeach;
echo '</ul>'; } function archive_shortcode( $atts, $content = null ) { ob_start(); $output = full_archive_helper(); $output .= ob_get_clean(); return $output; } if (!is_admin()) { add_shortcode("arch", "archive_shortcode"); } ?>






انشاء صفحة الارشيف

بعد قم بانشاء صفحة جديدة باسم الارشيف كامل واختر النموذج (Full Archive) ثم ضع الكود الموضح في الصورة ادناه وسط المقالة ثم انشرها
https://i0.wp.com/www.mwordpress.net...72%2C540&ssl=1
الان قم بمعاينة الارشيف لمشاهدة كيف سيظهر لك وهذا مثال على التعديل الذي اجرينا على قالب Twenty Sixteen
https://i2.wp.com/www.mwordpress.net...06%2C699&ssl=1
الى هنا نكن قد انتهينا من طريقة انشاء صفحة الأرشيف لمدونة الووردبريس والى اللقاء في تدوينة جديدة انشاء الله


الساعة الآن 04:57 AM

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2010, Crawlability, Inc. TranZ By Almuhajir

Security team