WP-Polls是一款WordPress投票插件,這款WordPress插件可以通過模板和CSS樣式進(jìn)行高度自定義,并且有很多選項(xiàng)供您選擇,以確保WP-Polls以您想要的方式運(yùn)行。現(xiàn)在,它支持一個(gè)問題與多種選擇答案。
- 插件介紹:WordPress



評價(jià)
可惜的是,只能添加一個(gè)問題和數(shù)個(gè)答案。在一些復(fù)雜的場景下,增加了使用難度。
一些用法
一般用法(無窗口小部件)
<?php if ( function_exists( 'vote_poll' ) && ! in_pollarchive() ): ?>
<li>
<h2>Polls</h2>
<ul>
<li><?php get_poll();?></li>
</ul>
<?php display_polls_archive_link(); ?>
</li>
<?php endif; ?>
- 要顯示特定的民意調(diào)查,請使用
<?php get_poll(2); ?>
其中2是您的民意調(diào)查ID。 - 要顯示隨機(jī)投票,請使用?
<?php get_poll(-2); ?>
- 要將特定民意調(diào)查嵌入到您的帖子中,請使用
[poll id="2"]
其中2是您的民意調(diào)查ID。 - 要在您的帖子中嵌入隨機(jī)意見調(diào)查,請使用?
[poll id="-2"]
- 要將特定民意調(diào)查的結(jié)果嵌入到您的帖子中,請使用
[poll id="2" type="result"]
其中2是您的民意調(diào)查ID。
一般用法(帶小部件)
- 轉(zhuǎn)到
WP-Admin -> Appearance -> Widgets
。 - 您可以通過單擊“小部件”小部件旁邊的“添加”鏈接來添加它。
- 添加之后,您可以通過單擊“小部件”旁邊的“編輯”鏈接來配置它。
- 點(diǎn)擊“保存更改”。
- 向下滾動以獲取有關(guān)如何創(chuàng)建輪詢存檔的說明。
如何添加民意測驗(yàn)檔案?
- 轉(zhuǎn)到
WP-Admin -> Pages -> Add New
。 - 在帖子的標(biāo)題區(qū)域中鍵入您喜歡的任何標(biāo)題。
- 如果您使用的是不錯(cuò)的永久鏈接,則在輸入標(biāo)題后,WordPress將生成該頁面的永久鏈接。您將在永久鏈接旁邊看到一個(gè)“編輯”鏈接。
- 單擊“編輯”,然后在
pollsarchive
文本字段中鍵入,然后單擊“保存”。 [page_polls]
在帖子的內(nèi)容區(qū)域中鍵入。- 點(diǎn)擊“發(fā)布”。
- 如果您沒有使用漂亮的永久鏈接,則需要轉(zhuǎn)到
WP-Admin -> Polls -> Poll Options
和下方Poll Archive -> Polls Archive URL
,您需要填寫上面創(chuàng)建的民意測驗(yàn)存檔頁面的URL。
為什么我的民意調(diào)查的答案加起來不是100%?
這是因?yàn)樗纳嵛迦雴栴}。為了使它始終取整到100%,上次民意測驗(yàn)的答案將添加剩余的百分比。要啟用此功能,請將其添加到主題的functions.php中:add_filter( 'wp_polls_round_percentage', '__return_true' );
WP輪詢?nèi)绾渭虞dCSS?
- WP-Polls
polls-css.css
將從您的主題目錄中加載(如果存在)。 - 如果不存在,它將僅加載
polls-css.css
WP-Polls隨附的默認(rèn)值。 - 這將使您可以升級WP-Poll,而不必?fù)?dān)心會覆蓋已創(chuàng)建的民意測驗(yàn)樣式。
為什么在Internet Explorer(IE)中,民意調(diào)查的文本顯示為鋸齒狀?
- 要解決此問題,請打開poll-css.css
- 找:?
/* background-color: #ffffff; */
- 替換:(
background-color: #ffffff;
其中#ffffff應(yīng)該是民意調(diào)查的背景色。)
如何為每個(gè)民意測驗(yàn)欄設(shè)置單獨(dú)的顏色?
- 由TreedBox.com提供
- 打開poll-css.css
- 添加到文件末尾:
.wp-polls-ul li:nth-child(01) .pollbar{ background:#8FA0C5}
.wp-polls-ul li:nth-child(02) .pollbar{ background:#FF8}
.wp-polls-ul li:nth-child(03) .pollbar{ background:#ff8a3b}
.wp-polls-ul li:nth-child(04) .pollbar{ background:#a61e2a}
.wp-polls-ul li:nth-child(05) .pollbar{ background:#4ebbff}
.wp-polls-ul li:nth-child(06) .pollbar{ background:#fbca54}
.wp-polls-ul li:nth-child(07) .pollbar{ background:#aad34f}
.wp-polls-ul li:nth-child(08) .pollbar{ background:#66cc9a}
.wp-polls-ul li:nth-child(09) .pollbar{ background:#98CBCB}
.wp-polls-ul li:nth-child(10) .pollbar{ background:#a67c52}
.wp-polls-ul li .pollbar{ transition: background 0.7s ease-in-out }
.wp-polls-ul li .pollbar:hover{ background:#F00 }
顯示總投票
<?php if ( function_exists( 'get_pollquestions' ) ): ?>
<?php get_pollquestions(); ?>
<?php endif; ?>
顯示總投票答案
<?php if ( function_exists( 'get_pollanswers' ) ): ?>
<?php get_pollanswers(); ?>
<?php endif; ?>
顯示投票總數(shù)
<?php if ( function_exists( 'get_pollvotes' ) ): ?>
<?php get_pollvotes(); ?>
<?php endif; ?>
通過ID顯示投票
<?php if ( function_exists( 'get_pollvotes_by_id' ) ): ?>
<?php get_pollvotes_by_id($poll_id); ?>
<?php endif; ?>
顯示投票總數(shù)
<?php if ( function_exists( 'get_pollvoters' ) ): ?>
<?php get_pollvoters(); ?>
<?php endif; ?>
通過ID和日期格式顯示輪詢時(shí)間
<?php if ( function_exists( 'get_polltime' ) ): ?>
<?php get_polltime( $poll_id, $date_format ); ?>
<?php endif; ?>