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

Bắt đầu Bạn cần có một chủ đề cơ bản có chứa một file , và tập tin một bên như tạo ra cho công thức này. Bạn cũng cần phải biết được nơi bạn muốn đặt danh sách của các tác giả thảo luận nhiều nhất. Trong ví dụ này, chúng tôi sẽ hiển thị các dữ liệu trong thanh bên một. | Chapter 9 Getting started You need to have a basic theme containing a file and a sidebar file such as created for this recipe. You also need to know where you would like to place the listing of the most discussed authors. In this example we will be displaying the data in a sidebar. How to do it. First we need to create a custom template tag. We ll call the template tag get_most_ discussed_authors and have it accept a single parameter that determines the number of results to return. Open or create your theme s file and define the function as follows function get_most_discussed_authors limit 3 global wpdb return wpdb- get_results wpdb- prepare SELECT COUNT wpdb- comments .comment_ID as number_comments wpdb- users .ID as user_ID FROM wpdb- comments wpdb- users wpdb- posts WHERE wpdb- users .ID wpdb- posts .post_author AND wpdb- posts .ID wpdb- comments .comment_post_ID GROUP BY wpdb- users .ID ORDER BY number_comments DESC LIMIT d limit Now we need to use this function to display information to visitors. Borrowing from the recipe Listing all published authors on a site we put the following code in one of our sidebars ul li Most Discussed Authors ul php discussed get_most_discussed_authors foreach discussed as item user_ID item- user_ID num_comments item- number_comments url get_author_posts_url user_ID li a href php echo url php echo get_the_author_meta display_name user_ID 185 185 Showing Author Information php printf _n d comment d comments num_comments num_comments a li php ul li ul Save the file and then upload it to the current theme folder on your server. If you ve done everything correctly you should have an output that looks something like the following screenshot of the sidebar Most Discussed Authors s Test User 5 - 3 comments Test User 7 - 2 comments Test User 9 - L comment How it works. As with the previous two recipes we ve created a template tag that basically acts as a delegate for a raw SQL call by using the wpdb

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.