0
我正在嘗試編寫一個插件,該插件將採用頁面標識並返回頁面的預覽。這裏是我的代碼:<!--more-->在顯示WordPress內容時被忽略
function page_preview($atts,$pageid = null) {
extract(shortcode_atts(array(
"pageid" => '0'
), $atts));
$the_query = new WP_Query('page_id=' . $pageid . '');
global $more;
$more = 0;
if ($the_query->have_posts()) {
while ($the_query->have_posts()) {
$the_query->the_post();
$title=get_the_title();
$thumbnail=get_the_post_thumbnail($pageid, 'preview');
$content=get_the_content();
}
}
return '<div class="callout">' .
'<h4>' .
$title .
'</h4>' .
$thumbnail .
$content . '<a href="' .
get_the_permalink($pageid) .
'">Continue reading</a></div>';
}
add_shortcode('pagepreview', 'page_preview');
連帶呼籲wpadmin編輯器,像這樣: [pagepreview的pageid = 11] [pagepreview的pageid = 13] [pagepreview的pageid = 8054] 即會顯示一個頁面預覽每個頁面ID。
「更多」不起作用。
global $more;
$more = 0;
通常解決了這個問題,但它不是我的情況。任何人都可以看到我的「M做錯了嗎?謝謝。
謝謝。試過這個,但仍然不起作用;我已經把$ more = 0放到了任何地方,但沒有成功...... –
你從插件獲得了什麼輸出?您是否獲得了該帖子的全部內容(更多標籤的上方和下方)或其他內容? – vvanasten
獲取郵件的完整輸出,在上面和下面。 –