1. Get bài viết mới nhất

                Sử dụng đoạn code lấy bài viết mặc định

                                    <?php if (have_posts()) : ?>

                                    <?php while (have_posts()) : the_post(); ?>

                                    <?php endwhile; else : ?>

                                    <p>Không có</p>

                                    <?php endif; ?>

                Đoạn code đặt trong index sẽ lấy list bài viết mới nhất, Đặt trong category sẽ lấy danh sách bài viết của category đó, đặt trong single sẽ lấy nội dung của bài đó!.

                – Chỉnh sửa các thông số php phù hợp để lấy thông tin

                – Muốn tùy chỉnh số lượng bài viết thì vào admin (cài đặt/đọc)

                2. Phân trang, sử dụng đoạn code sau để phân trang, Code này thường chèn dưới đoạn code số 1 (Code get post mặt định)

                        <?php if(paginate_links()!=”) {?>

                        <div class=”quatrang”>

                        <?php

                                    global $wp_query;

                                    $big = 999999999;

                                    echo paginate_links( array(

                        ‘base’ => str_replace( $big, ‘%#%’, esc_url( get_pagenum_link( $big ) ) ),

                        ‘format’ => ‘?paged=%#%’,

                        ‘prev_text’    => __(‘«’),

                        ‘next_text’    => __(‘»’),

                        ‘current’ => max( 1, get_query_var(‘paged’) ),

                        ‘total’ => $wp_query->max_num_pages

                        ) );

                            ?>

                        </div>

                        <?php } ?>

                3. Get chuyên mục

                <ul>

                                    <?php

                                                $args = array(

                                                    ‘child_of’  => 0,

                                                    ‘<strong>orderby</strong>’    => ‘id’,

                                                );

                                                $categories = get_categories( $args );

                                                foreach ( $categories as $category ) { ?>

                                                <li>

                                                   <a href=”<?php echo get_term_link($category->slug, ‘category’);?>”>

                                                      <?php echo $category->name ; ?>

                                                     <span> (<?php echo $category->count;?>)</span>

                                                   </a>

                                                </li>

                                    <?php } ?>

                        </ul>

                4. Lấy bài viết mới nhất: sử dụng hàm new WP_query

                <ul>

                                    <?php $getposts = new WP_query(); $getposts->query(‘post_status=publish&showposts=5&post_type=post’); ?>

                                    <?php global $wp_query; $wp_query->in_the_loop = true; ?>

                                    <?php while ($getposts->have_posts()) : $getposts->the_post(); ?>

                                                <li>

                                                            <a href=”<?php the_permalink(); ?>”><?php echo get_the_post_thumbnail( $get_the_id, ‘full’, array( ‘class’ =>’thumnail’) ); ?></a>

                                                            <h4><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></h4>

                                                            <div class=”meta”><span>Ngày đăng: <?php echo get_the_date(‘d – m – Y’) ?></span></div>

                                                            <div class=”clear”></div>

                                                </li>

                                    <?php endwhile; wp_reset_postdata(); ?>

                        </ul>

                5. Nhúng facebook vào sidebar web

                – Vào google seach plugin page facebook (https://developers.facebook.com/docs/plugins/page-plugin?locale=vi_VN)

                – Tùy chỉnh hiển thị theo ý rồi lấy mã

                – Copy đoạn code step 2 vào dưới thẻ footer trong file footer.php

                <div id=”fb-root”></div>

                <script async defer crossorigin=”anonymous”                 src=”https://connect.facebook.net/vi_VN/sdk.js#xfbml=1&version=v4.0&appId=376128953252614&autoLogAppEvents=1″></script>

                – Đoạn code step 3, copy vào phần facebook file sidebar.php

                <div class=”content-fb”>

                        <div class=”fb-page” data-href=”https://www.facebook.com/Nh&#xe0;-&#x111;&#x1ea5;t-L&#x1ea1;ng-S&#x1a1;n-418113289043728/” data-tabs=”timeline” data-width=”” data-height=”” data-small-header=”false” data-adapt-container-width=”true” data-hide-cover=”false” data-show-facepile=”true”><blockquote cite=”https://www.facebook.com/Nh&#xe0;-&#x111;&#x1ea5;t-L&#x1ea1;ng-S&#x1a1;n-418113289043728/” class=”fb-xfbml-parse-ignore”><a href=”https://www.facebook.com/Nh&#xe0;-&#x111;&#x1ea5;t-L&#x1ea1;ng-S&#x1a1;n-418113289043728/”>Nhà đất Lạng Sơn</a></blockquote></div>

                </div>