目錄
回复内容:
首頁 後端開發 php教程 WordPress中的评分插件 调用。

WordPress中的评分插件 调用。

Jun 06, 2016 pm 08:45 PM
php wordpress 外掛

安装了WordPress,其中也添加了自己写的HTML静态页面,

现在想调用这个WordPress中的评分插件,怎么让我的自己写的页面, 伪装成一篇WordPress发表的新文章?
让我写的页面也具有评分功能。

现在已经 知道, 使用 [rate] 可以调用评分插件,但高级自定义还是不太会。.

下面是说明文档:

= How do I manually get the most rated posts using PHP? =

$posts = PostRatings()->getTopRated($arguments);

Possible arguments, and their defaults:

<code>'post_type`    =&gt; 'post',
'number'       =&gt; 10,                   // max. number of posts to retrieve
'offset'       =&gt; 0,                    // offset from where to start
'sortby'       =&gt; 'bayesian_rating',    // bayesian_rating, rating or votes
'order'        =&gt; 'DESC',               // ASC or DESC
'date_limit'   =&gt; 0,                    // date limit in days
</code>
登入後複製
登入後複製

Return value is an array of post objects containing the usual post properties + 3 extra properties:

<code>$post-&gt;votes                            // number of votes
$post-&gt;rating                           // average rating
$post-&gt;bayesian_rating                  // weighted rating
</code>
登入後複製
登入後複製

Example usage:

<code>global $post;
$results = PostRatings()-&gt;getTopRated();

foreach($results as $post){
  setup_postdata($post); ?&gt;

  // here is the usual loop
  <?php the_title(); ?> - <?php printf(_n('%d vote', '%d votes', $post->votes), $post-&gt;votes); ?&gt;

  <?php }

// restore original post
wp_reset_postdata();
</code></code>
登入後複製
登入後複製

回复内容:

安装了WordPress,其中也添加了自己写的HTML静态页面,

现在想调用这个WordPress中的评分插件,怎么让我的自己写的页面, 伪装成一篇WordPress发表的新文章?
让我写的页面也具有评分功能。

现在已经 知道, 使用 [rate] 可以调用评分插件,但高级自定义还是不太会。.

下面是说明文档:

= How do I manually get the most rated posts using PHP? =

$posts = PostRatings()-&gt;getTopRated($arguments);

Possible arguments, and their defaults:

<code>'post_type`    =&gt; 'post',
'number'       =&gt; 10,                   // max. number of posts to retrieve
'offset'       =&gt; 0,                    // offset from where to start
'sortby'       =&gt; 'bayesian_rating',    // bayesian_rating, rating or votes
'order'        =&gt; 'DESC',               // ASC or DESC
'date_limit'   =&gt; 0,                    // date limit in days
</code>
登入後複製
登入後複製

Return value is an array of post objects containing the usual post properties + 3 extra properties:

<code>$post-&gt;votes                            // number of votes
$post-&gt;rating                           // average rating
$post-&gt;bayesian_rating                  // weighted rating
</code>
登入後複製
登入後複製

Example usage:

<code>global $post;
$results = PostRatings()-&gt;getTopRated();

foreach($results as $post){
  setup_postdata($post); ?&gt;

  // here is the usual loop
  <?php the_title(); ?> - <?php printf(_n('%d vote', '%d votes', $post->votes), $post-&gt;votes); ?&gt;

  <?php }

// restore original post
wp_reset_postdata();
</code></code>
登入後複製
登入後複製
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
2 週前 By 尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
2 週前 By 尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱門文章標籤

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

適用於 Ubuntu 和 Debian 的 PHP 8.4 安裝和升級指南 適用於 Ubuntu 和 Debian 的 PHP 8.4 安裝和升級指南 Dec 24, 2024 pm 04:42 PM

適用於 Ubuntu 和 Debian 的 PHP 8.4 安裝和升級指南

CakePHP 專案配置 CakePHP 專案配置 Sep 10, 2024 pm 05:25 PM

CakePHP 專案配置

CakePHP 日期和時間 CakePHP 日期和時間 Sep 10, 2024 pm 05:27 PM

CakePHP 日期和時間

CakePHP 檔案上傳 CakePHP 檔案上傳 Sep 10, 2024 pm 05:27 PM

CakePHP 檔案上傳

CakePHP 路由 CakePHP 路由 Sep 10, 2024 pm 05:25 PM

CakePHP 路由

討論 CakePHP 討論 CakePHP Sep 10, 2024 pm 05:28 PM

討論 CakePHP

如何設定 Visual Studio Code (VS Code) 進行 PHP 開發 如何設定 Visual Studio Code (VS Code) 進行 PHP 開發 Dec 20, 2024 am 11:31 AM

如何設定 Visual Studio Code (VS Code) 進行 PHP 開發

CakePHP 快速指南 CakePHP 快速指南 Sep 10, 2024 pm 05:27 PM

CakePHP 快速指南

See all articles