Dưới đây là cách hiển thị bài viết theo chuyên mục (Recent Post WordPress) trong WordPress, với đoạn code này chúng ta có thể hoàn toàn tùy biến chúng.
Bài viết dành cho các bạn đang làm nghề thiết kế WordPress, WordPress Delelopment, thiết kế theme WordPress.
Bước 1: Tạo 1 file có tên loop-web5c1.php trong thư mục theme WordPress với nội dung sau:
<?php for ($i = 1; $i <= 1; $i++) {?> <a href='<?php the_permalink(); ?>' title='<?php the_title();?>'> <?php the_post_thumbnail('skip_post_thumb'); ?> <h1><?php the_title();?></h1> <p><?php the_excerpt(); ?></p> </a> <?php }?>
- Bước 2: Chèn đoạn code sau vào nơi cần hiển thị bài viết, Recent post
<?php query_posts('showposts=1&category_name=khach-hang-doi-tac&orderby=DESC'); if (have_posts()): while (have_posts()): the_post(); {get_template_part('loop', 'web5c1');} endwhile; wp_reset_query(); endif; ?>
** Nếu muốn hiển thị bài viết cho toàn trang web WordPress, hãy chỉnh sửa nó trở thành như sau:
<?php query_posts('showposts=1&orderby=DESC'); if (have_posts()): while (have_posts()): the_post(); {get_template_part('loop', 'web5c1');} endwhile; wp_reset_query(); endif; ?>
Ví dụ: đoạn code ở bước 2, bạn đã hiển thị được 1 bài. Giờ đây, bạn muốn hiển thị thêm 2 bài liên tiếp (trừ bài đầu tiên) thì dùng đoạn code sau đây:
<?php query_posts('offset=1&showposts=2&category_name=khach-hang-doi-tac&orderby=DESC'); if (have_posts()): while (have_posts()): the_post(); {get_template_part('loop', 'web5c1');} endwhile; wp_reset_query(); endif; ?>
[url=https://synthroidam.online/]buy synthroid from canada[/url]
[url=https://lisinoprildrl.online/]lisinopril brand name canada[/url]
etsyweddingteam.com
この記事から得られる知識は計り知れません。非常に感謝しています。
[url=https://ametformin.com/]metformin with no prescription[/url]
[url=https://arusak-attestats.ru/]http://arusak-attestats.ru[/url] – Аттестат купить окончание – возможность для вашему перспективам. В нашем портале вы сможете просто и оперативно купить свидетельство, необходимый для последующего получения образования или профессионального роста. Наши консультанты гарантируют качество и секретность услуги. Приобретайте учебный аттестат в нашем сервисе и откройте новые возможности для вашего карьерного развития и карьеры.
[url=http://happyfamilystorerx.online/]canadian pharmacy world[/url]
[url=https://medicinesaf.online/]canadianpharmacy com[/url]
[url=https://lisinoprilgp.online/]lisinopril 30 mg tablet[/url]
[url=http://tadalafi.online/]buy tadalafil india[/url]
sandyterrace.com
물론 Fang Jifan은 그와 전혀 우정이 없으며 어디서부터 시작해야할지 친절합니다.
largestcatbreed.com
“노예…” 왕얀은 급히 무릎을 꿇고 슬픈 얼굴로 말했다. “노예는 영원히 죽을 것이다.”
werankcities.com
그 남자는 다시 어안이 벙벙했고 Deng Jian이 일을 엉망으로 만들기 위해 여기에 있다고 의심하기 시작했습니다.
fpparisshop.com
読後感が良い。心から感動しました。
You actually make it seem so easy with your presentation but
I find this topic to be really something
that I think I would never understand. It seems too complex and extremely broad for
me. I’m looking forward for your next post, I’ll
try to get the hang of it!
[url=http://tadalafilstd.online/]buy cialis 2.5 mg online[/url]