[WordPress] 外掛分享: TTT Loadmore

首頁外掛目錄 › TTT Loadmore
WordPress 外掛 TTT Loadmore 的封面圖片
10+
安裝啟用
尚無評分
3839 天前
最後更新
問題解決
WordPress 3.7+ v1.1.1 上架:2015-09-06

內容簡介

這是一個 WordPress 外掛,可以使用自己的模板載入更多事件。

如果要進行代碼貢獻,請前往 https://github.com/33themes/ttt-loadmore。

如何使用

這是基本的 HTML 結構:

<a href="#" data-tttloadmore-do="archiveposts" data-tttloadmore-to="#main" data-tttloadmore-args="category:php;">
載入更多內容
</a>

data-tttloadmore-do* 是載入更多內容的動作
data-tttloadmore-to* 是載入更多文章後(“do”動作的結果)腳本放置內容的位置
data-tttloadmore-args* 包含您要發送到“do”動作的所有參數

然後,您必須使用與 data-tttloadmore-do 相同名稱的動作

<?php
function loadmore_archiveposts( $page, $args = false ){

$archiveposts = array(
'post_type' => 'post',
'post_status' => 'publish',
'order' => 'DESC',
'orderby' => 'date',
'paged' => $page,
'ignore_sticky_posts' => 1,
'category_name' => $args['category'],
);
$archiveposts_query = new WP_Query($archiveposts);
?>

<?php if ($archiveposts_query->have_posts()) : ?>
<?php while ($archiveposts_query->have_posts()) : $archiveposts_query->the_post(); ?>
<?php get_template_part( 'partials/content', 'content' ); ?>
<?php wp_reset_postdata();?>
<?php endwhile; ?>
<?php endif;?>

<?
}
add_action('ttt_loadmore_archiveposts','loadmore_archiveposts', 1, 2);
?>

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.1.1) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「TTT Loadmore」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

WordPress plugin to load more event with your own template.
For code contributions please go to https://github.com/33themes/ttt-loadmore
How to use it
This is the base html:

Load more content

data-tttloadmore-do* is the action to load more content
data-tttloadmore-to* is where the script put the content after load more posts (the result of the “do” action)
data-tttloadmore-args* contain all the arguments you want to send to the “do” action

Then, you have to create an action with the same name of the data-tttloadmore-do
'post',
'post_status' => 'publish',
'order' => 'DESC',
'orderby' => 'date',
'paged' => $page,
'ignore_sticky_posts' => 1,
'category_name' => $args['category'],
);
$archiveposts_query = new WP_Query($archiveposts);
?>

have_posts()) : ?>
have_posts()) : $archiveposts_query->the_post(); ?>



延伸相關外掛

文章
Filter
Apply Filters
Mastodon