
內容簡介
這是一個 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);
?>
外掛標籤
開發者團隊
原文外掛簡介
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(); ?>
} add_action('ttt_loadmore_archiveposts','loadmore_archiveposts', 1, 2); ?>
