Diff
checker
Testo
Testo
Immagini
Documenti
Excel
Cartelle
Legal
Enterprise
Applicazione per desktop
Prezzi
Accedi
Scarica Diffchecker Desktop
Confronta il testo
Trova la differenza tra due file di testo
Strumenti
Cronologia
Editor live
Nascondi spazi bianchi
Comprimi invariate
Senza a capo
Layout
Diviso
Unificato
Livello di dettaglio
Intelligente
Parola
Carattere
Stili testo
Modifica aspetto
Evidenziazione sintassi
Scegli sintassi
Ignora
Trasforma testo
Vai alla prima modifica
Modifica input
Diffchecker Desktop
Il modo più sicuro per usare Diffchecker. Ottieni l'app Diffchecker Desktop: i tuoi diff non lasciano mai il tuo computer!
Ottieni Desktop
Untitled diff
Creato
10 anni fa
Il diff non scade mai
Eliminare
Esporta
Condividere
Spiegare
32 rimozioni
Linee
Totale
Rimosso
Caratteri
Totale
Rimosso
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
85 linee
Copia tutti
3 aggiunte
Linee
Totale
Aggiunto
Caratteri
Totale
Aggiunto
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
56 linee
Copia tutti
<?php
<?php
Copia
Copiato
Copia
Copiato
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';
Copia
Copiato
Copia
Copiato
$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' );
Diff salvati
Testo originale
Apri file
<?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' );
Testo modificato
Apri file
<?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' );
Trovare la differenza