Diff
checker
文本
文本
图像
文档
Excel
文件夹
Legal
Enterprise
桌面版
定价
登录
下载 Diffchecker 桌面版
比较文本
查找两个文本文件之间的差异
工具
历史
实时编辑器
隐藏空白更改
折叠未更改行
关闭换行
视图
拆分
统一
比对精度
智能
单词
字符
文本样式
更改外观
语法高亮
选择语法
忽略
文本转换
转到第一个差异
编辑输入
Diffchecker Desktop
运行Diffchecker最安全的方式。获取Diffchecker桌面应用:您的差异永远不会离开您的电脑!
获取桌面版
Untitled diff
创建于
10年前
差异永不过期
清除
导出
分享
解释
32 删除
行
总计
删除
字符
总计
删除
要继续使用此功能,请升级到
Diff
checker
Pro
查看价格
85 行
全部复制
3 添加
行
总计
添加
字符
总计
添加
要继续使用此功能,请升级到
Diff
checker
Pro
查看价格
56 行
全部复制
<?php
<?php
复制
已复制
复制
已复制
function init_load_posts() {
// Grid Loop Query Args
add_action( 'pre_get_posts', 'be_grid_loop_query_args' );
}
add_action( 'init', 'init_load_posts' );
function be_grid_loop_query_args( $query ) {
//if( $query->is_main_query() && !is_admin() ) {
// First Page
$page = $_POST['page'];
if( ! $page ) {
$query->set( 'posts_per_page', 7 );
// Other Pages
} else {
$query->set( 'posts_per_page', 2 );
// Offset is posts on first page + posts on internal pages * ( current page - 2 )
// example $args['offset'] = 5 + 2 * ( $page - 2) - 5 posts on home page, 2 posts on subsequent pages
$query->set( 'offset', 7 + 2 * ( $page - 2 ) );
}
//}
}
/**
/**
* Javascript for Load More
* Javascript for Load More
*
*
*/
*/
function be_load_more_js() {
function be_load_more_js() {
global $wp_query;
global $wp_query;
$args = array(
$args = array(
'nonce' => wp_create_nonce( 'be-load-more-nonce' ),
'nonce' => wp_create_nonce( 'be-load-more-nonce' ),
'url' => admin_url( 'admin-ajax.php' ),
'url' => admin_url( 'admin-ajax.php' ),
'query' => $wp_query->query,
'query' => $wp_query->query,
);
);
wp_enqueue_script( 'be-load-more', get_stylesheet_directory_uri() . '/js/load-more.js', array( 'jquery' ), '1.0', true );
wp_enqueue_script( 'be-load-more', get_stylesheet_directory_uri() . '/js/load-more.js', array( 'jquery' ), '1.0', true );
wp_localize_script( 'be-load-more', 'beloadmore', $args );
wp_localize_script( 'be-load-more', 'beloadmore', $args );
}
}
add_action( 'wp_enqueue_scripts', 'be_load_more_js', 10 );
add_action( 'wp_enqueue_scripts', 'be_load_more_js', 10 );
/**
/**
* AJAX Load More
* AJAX Load More
*
*
*/
*/
/*
/*
* Use your query here. Remember that if you make a call to $custom->the_post()
* Use your query here. Remember that if you make a call to $custom->the_post()
* you'll need to reset the post data after the loop by calling wp_reset_postdata().
* you'll need to reset the post data after the loop by calling wp_reset_postdata().
*/
*/
function be_ajax_load_more() {
function be_ajax_load_more() {
check_ajax_referer( 'be-load-more-nonce', 'nonce' );
check_ajax_referer( 'be-load-more-nonce', 'nonce' );
$args = isset( $_POST['query'] ) ? $_POST['query'] : array();
$args = isset( $_POST['query'] ) ? $_POST['query'] : array();
$args['post_type'] = isset( $args['post_type'] ) ? $args['post_type'] : 'post';
$args['post_type'] = isset( $args['post_type'] ) ? $args['post_type'] : 'post';
$args['paged'] = $_POST['page'];
$args['paged'] = $_POST['page'];
$args['post_status'] = 'publish';
$args['post_status'] = 'publish';
复制
已复制
复制
已复制
$args['posts_per_page'] = 2;
$args['offset'] = 7 + 2 * ( $_POST['page'] - 2 );
$loop = new WP_Query( $args );
$loop = new WP_Query( $args );
if( $loop->have_posts() ): while( $loop->have_posts() ): $loop->the_post();
if( $loop->have_posts() ): while( $loop->have_posts() ): $loop->the_post();
echo '<h1>' . the_title() . '</h1>';
echo '<h1>' . the_title() . '</h1>';
echo '<p>' . $args['paged'] . '</p>';
echo '<p>' . $args['paged'] . '</p>';
endwhile; endif; wp_reset_postdata();
endwhile; endif; wp_reset_postdata();
$data = ob_get_clean();
$data = ob_get_clean();
wp_send_json_success( $data );
wp_send_json_success( $data );
}
}
add_action( 'wp_ajax_be_ajax_load_more', 'be_ajax_load_more' );
add_action( 'wp_ajax_be_ajax_load_more', 'be_ajax_load_more' );
add_action( 'wp_ajax_nopriv_be_ajax_load_more', 'be_ajax_load_more' );
add_action( 'wp_ajax_nopriv_be_ajax_load_more', 'be_ajax_load_more' );
已保存差异
原始文本
打开文件
<?php function init_load_posts() { // Grid Loop Query Args add_action( 'pre_get_posts', 'be_grid_loop_query_args' ); } add_action( 'init', 'init_load_posts' ); function be_grid_loop_query_args( $query ) { //if( $query->is_main_query() && !is_admin() ) { // First Page $page = $_POST['page']; if( ! $page ) { $query->set( 'posts_per_page', 7 ); // Other Pages } else { $query->set( 'posts_per_page', 2 ); // Offset is posts on first page + posts on internal pages * ( current page - 2 ) // example $args['offset'] = 5 + 2 * ( $page - 2) - 5 posts on home page, 2 posts on subsequent pages $query->set( 'offset', 7 + 2 * ( $page - 2 ) ); } //} } /** * Javascript for Load More * */ function be_load_more_js() { global $wp_query; $args = array( 'nonce' => wp_create_nonce( 'be-load-more-nonce' ), 'url' => admin_url( 'admin-ajax.php' ), 'query' => $wp_query->query, ); wp_enqueue_script( 'be-load-more', get_stylesheet_directory_uri() . '/js/load-more.js', array( 'jquery' ), '1.0', true ); wp_localize_script( 'be-load-more', 'beloadmore', $args ); } add_action( 'wp_enqueue_scripts', 'be_load_more_js', 10 ); /** * AJAX Load More * */ /* * Use your query here. Remember that if you make a call to $custom->the_post() * you'll need to reset the post data after the loop by calling wp_reset_postdata(). */ function be_ajax_load_more() { check_ajax_referer( 'be-load-more-nonce', 'nonce' ); $args = isset( $_POST['query'] ) ? $_POST['query'] : array(); $args['post_type'] = isset( $args['post_type'] ) ? $args['post_type'] : 'post'; $args['paged'] = $_POST['page']; $args['post_status'] = 'publish'; $loop = new WP_Query( $args ); if( $loop->have_posts() ): while( $loop->have_posts() ): $loop->the_post(); echo '<h1>' . the_title() . '</h1>'; echo '<p>' . $args['paged'] . '</p>'; endwhile; endif; wp_reset_postdata(); $data = ob_get_clean(); wp_send_json_success( $data ); } add_action( 'wp_ajax_be_ajax_load_more', 'be_ajax_load_more' ); add_action( 'wp_ajax_nopriv_be_ajax_load_more', 'be_ajax_load_more' );
更改后文本
打开文件
<?php /** * Javascript for Load More * */ function be_load_more_js() { global $wp_query; $args = array( 'nonce' => wp_create_nonce( 'be-load-more-nonce' ), 'url' => admin_url( 'admin-ajax.php' ), 'query' => $wp_query->query, ); wp_enqueue_script( 'be-load-more', get_stylesheet_directory_uri() . '/js/load-more.js', array( 'jquery' ), '1.0', true ); wp_localize_script( 'be-load-more', 'beloadmore', $args ); } add_action( 'wp_enqueue_scripts', 'be_load_more_js', 10 ); /** * AJAX Load More * */ /* * Use your query here. Remember that if you make a call to $custom->the_post() * you'll need to reset the post data after the loop by calling wp_reset_postdata(). */ function be_ajax_load_more() { check_ajax_referer( 'be-load-more-nonce', 'nonce' ); $args = isset( $_POST['query'] ) ? $_POST['query'] : array(); $args['post_type'] = isset( $args['post_type'] ) ? $args['post_type'] : 'post'; $args['paged'] = $_POST['page']; $args['post_status'] = 'publish'; $args['posts_per_page'] = 2; $args['offset'] = 7 + 2 * ( $_POST['page'] - 2 ); $loop = new WP_Query( $args ); if( $loop->have_posts() ): while( $loop->have_posts() ): $loop->the_post(); echo '<h1>' . the_title() . '</h1>'; echo '<p>' . $args['paged'] . '</p>'; endwhile; endif; wp_reset_postdata(); $data = ob_get_clean(); wp_send_json_success( $data ); } add_action( 'wp_ajax_be_ajax_load_more', 'be_ajax_load_more' ); add_action( 'wp_ajax_nopriv_be_ajax_load_more', 'be_ajax_load_more' );
查找差异