TAILIEUCHUNG - Hướng dẫn tạo themes cho wordpress part 6

Tạo một bài dính trên blog thử nghiệm của bạn và hãy xem tại trang chủ của trang web. Bạn sẽ thấy văn bản thêm vào các bài dính, và sau này nên được chuyển đến đầu của The Loop. Bạn có thể thấy điều này trong các ảnh chụp màn hình sau đây: | Chapter 3 div class sticky-announcer p This post is sticky. p div php Create a sticky post on your test blog and take a look at your site s front page. You should see text appended to the sticky post and the post should be moved to the top of The Loop. You can see this in the following screenshot How it works. The is_sticky function checks the currently-active post to see if it is a sticky post. It does this by examining the value retrieved by calling get_option sticky_posts which is an array and trying to find the active post s ID in that array. The Loop In this case if the post is sticky then the sticky-announcer div is output with a message. However there is no limit to what you can do once you ve determined if a post is sticky. Some ideas include Displaying a special icon for sticky posts Changing the background color of sticky posts Adding content dynamically to sticky posts Displaying post content differently for sticky posts Creating multiple loops in a single template In advanced themes there are often situations where you would want to display multiple Loops consisting of posts with different criteria. When doing so you should make sure not to alter the normal default Loop or else some template tags will not work appropriately. How to do it. First decide what kind of Loops you want to create. Perhaps you want to create two Loops based on different categories. Perhaps one Loop should have featured posts while the other has the default posts based on the page URL. For this example we re going to create two category Loops. To create the two category Loops you need to create two separate instances of the WP_Query class. Copy the following code snippet into one of your template files php query1 new WP_Query array cat get_cat_ID aciform if query1- have_posts h1 Aciform Posts h1 php while query1- have_posts query1- the_post h2 php the_title h2 php echo hr query2 new WP_Query array cat get_cat_ID Cat B if query2- have_posts h1 Cat B Posts h1 php while query2- .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.