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

Tự động giới hạn số từ nội dung Trong một số trường hợp, bạn có thể hiển thị một số cụ thể của các từ từ nội dung của bài, có lẽ trong một vòng lặp nhỏ gọn cho các bài viết cũ hoặc là một phần của một phần asides | Chapter 4 There s more. WordPress defines a wide variety of PHP functions that retrieve or print information about the currently-active post. The following functions are the most frequently-used functions in any template the_ID the_title the_title_attribute the_content the_excerpt the_category the_tags next_post_link next_posts_link previous_post_link previous_posts_link The purpose of most of these functions is self-explanatory but you should try each of them in a template to see what kind of output you end up with. In addition you can see the complete list of template tags and the corresponding documentation for posts and otherwise at http Template_Tags . See also Creating a basic Loop Automatically limiting the number of words of content In some instances you may wish to display a specific number of words from a post s content perhaps in a compact loop for older posts or as part of an asides section in a blog s sidebar. This recipe shows you how to go about it. Template Tags How to do it. First open or create your file. This file resides in your theme s root directory. You re going to create a custom template tag for your theme and the file is the proper place to do so. Inside of your file place the following code php function limited_the_content number_words 200 global post stripped_content strip_tags post- post_content words explode stripped_content if count words number_words echo stripped_content else words array_slice words 0 number_words echo implode words You ll use this function in place of the_content to display your post s content. Open one of your theme s template files such as and insert the following code inside The Loop php limited_the_content number_words Replace the number_words variable in the above code snippet with whatever number of words you wish to display. You can check the difference between the_content and limited_the_content by using the following Loop php if .

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.