如何通過wordpress中的短代碼在單頁上顯示所有推薦?
問題描述:
i have created shortcode to show all testimonial on one page.
i have created custom post type to add each testimonial.
can anybody tell me how to show all testimonial on single page .
this code is used to create sshortcode
below i m mentioning code :-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
function fn_testimonials_block() { $args = array( \'post_type\'=> \'testimonials\', \'order\' => \'ASC\' ); $the_query = new WP_Query( $args ); $pages = $the_query->posts; //echo \"<pre>\"; //print_r($pages); //echo \"</pre>\"; //exit; $output = \'\'; $count = 1; foreach($pages as $page) { //----------------- $author = $page->post_title; $testimonial = $page->post_content; $page_url = get_page_link( $page->ID ); $author_image = get_the_post_thumbnail_url( $page->ID, \'thumbnail\' ); if ($count%2 == 1) { $output .= \'<div>\'; } $output .= \'<div> <p>\'.$testimonial.\'<br> <img src=\"\'.$author_image .\'\"> <span>\'.$author.\', </span></p> </div>\'; if ($count%2 == 0) { $output .= \'</div>\'; } $count++; } if ($count%4 != 1){ $output .= \'</div>\'; } return $output; } |
網友觀點:
I think you will have to pass \'posts_per_page\' key in $args array. So your $args array will look like this
1 2 3 4 5 6 |
$args = array( \'post_type\'=> \'testimonials\', \'order\' => \'ASC\', \'posts_per_page\' => \'-1\' ); |
I am not sure about the $count variable you are using. I suppose you are trying to implement logic for pagination there but since your question is about showing all testimonials on single page, I won\'t get into that part.
Making changes in $args will return all testimonials objects.
由於網站搬家,部分鏈接失效,如無法下載,請聯繫站長!謝謝支持!
1. 帶 [親測] 說明源碼已經被站長親測過!
2. 下載後的源碼請在24小時內刪除,僅供學慣用途!
3. 分享目的僅供大家學習和交流,請不要用於商業用途!
4. 本站資源售價只是贊助,收取費用僅維持本站的日常運營所需!
5. 本站所有資源來源於站長上傳和網路,如有侵權請郵件聯繫站長!
6. 沒帶 [親測] 代表站長時間緊促,站長會保持每天更新 [親測] 源碼 !
7. 盜版ripro用戶購買ripro美化無擔保,若設置不成功/不生效我們不支持退款!
8. 本站提供的源碼、模板、插件等等其他資源,都不包含技術服務請大家諒解!
9. 如果你也有好源碼或者教程,可以到審核區發布,分享有金幣獎勵和額外收入!
10.如果您購買了某個產品,而我們還沒來得及更新,請聯繫站長或留言催更,謝謝理解 !
GG資源網 » 如何通過wordpress中的短代碼在單頁上顯示所有推薦?
1. 帶 [親測] 說明源碼已經被站長親測過!
2. 下載後的源碼請在24小時內刪除,僅供學慣用途!
3. 分享目的僅供大家學習和交流,請不要用於商業用途!
4. 本站資源售價只是贊助,收取費用僅維持本站的日常運營所需!
5. 本站所有資源來源於站長上傳和網路,如有侵權請郵件聯繫站長!
6. 沒帶 [親測] 代表站長時間緊促,站長會保持每天更新 [親測] 源碼 !
7. 盜版ripro用戶購買ripro美化無擔保,若設置不成功/不生效我們不支持退款!
8. 本站提供的源碼、模板、插件等等其他資源,都不包含技術服務請大家諒解!
9. 如果你也有好源碼或者教程,可以到審核區發布,分享有金幣獎勵和額外收入!
10.如果您購買了某個產品,而我們還沒來得及更新,請聯繫站長或留言催更,謝謝理解 !
GG資源網 » 如何通過wordpress中的短代碼在單頁上顯示所有推薦?