Passed
Push — development ( f02a5c...230a66 )
by
unknown
02:37
created
inc/load-more.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 		global $wp_query; // you can remove this line if everything works for you
15 15
 
16 16
 		// don't display the button if there are not enough posts
17
-		if (  $wp_query->max_num_pages > 1 )
17
+		if ( $wp_query->max_num_pages > 1 )
18 18
 			echo '<div class="spurs_loadmore btn btn-primary btn-lg mx-auto w-25">More posts</div>'; // you can use <a> as well
19 19
 	}
20 20
 }
21 21
 
22 22
 
23
-function spurs_loadmore_ajax_handler(){
23
+function spurs_loadmore_ajax_handler() {
24 24
  
25 25
 	// prepare our arguments for the query
26 26
 	$args = json_decode( stripslashes( $_POST['query'] ), true );
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
 	// it is always better to use WP_Query but not here
32 32
 	query_posts( $args );
33 33
  
34
-	if( have_posts() ) :
34
+	if ( have_posts() ) :
35 35
  
36 36
 		// run the loop
37
-		while( have_posts() ): the_post();
37
+		while ( have_posts() ): the_post();
38 38
  
39 39
 			// look into your theme code how the posts are inserted, but you can use your own HTML of course
40 40
 			// do you remember? - my example is adapted for Twenty Seventeen theme
41
-			if( true == $search_page ){
41
+			if ( true == $search_page ) {
42 42
 				get_template_part( 'templates/loop/content', 'search' );
43 43
 			} else {
44 44
 				get_template_part( 'templates/loop/content', get_post_format() );
@@ -52,5 +52,5 @@  discard block
 block discarded – undo
52 52
 	endif;
53 53
 	die; // here we exit the script and even no wp_reset_query() required!
54 54
 }
55
-add_action('wp_ajax_loadmore', 'spurs_loadmore_ajax_handler'); // wp_ajax_{action}
56
-add_action('wp_ajax_nopriv_loadmore', 'spurs_loadmore_ajax_handler'); // wp_ajax_nopriv_{action}
57 55
\ No newline at end of file
56
+add_action( 'wp_ajax_loadmore', 'spurs_loadmore_ajax_handler' ); // wp_ajax_{action}
57
+add_action( 'wp_ajax_nopriv_loadmore', 'spurs_loadmore_ajax_handler' ); // wp_ajax_nopriv_{action}
58 58
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,13 +14,15 @@  discard block
 block discarded – undo
14 14
 		global $wp_query; // you can remove this line if everything works for you
15 15
 
16 16
 		// don't display the button if there are not enough posts
17
-		if (  $wp_query->max_num_pages > 1 )
18
-			echo '<div class="spurs_loadmore btn btn-primary btn-lg mx-auto w-25">More posts</div>'; // you can use <a> as well
17
+		if (  $wp_query->max_num_pages > 1 ) {
18
+					echo '<div class="spurs_loadmore btn btn-primary btn-lg mx-auto w-25">More posts</div>';
19
+		}
20
+		// you can use <a> as well
19 21
 	}
20 22
 }
21 23
 
22 24
 
23
-function spurs_loadmore_ajax_handler(){
25
+function spurs_loadmore_ajax_handler() {
24 26
  
25 27
 	// prepare our arguments for the query
26 28
 	$args = json_decode( stripslashes( $_POST['query'] ), true );
@@ -38,7 +40,7 @@  discard block
 block discarded – undo
38 40
  
39 41
 			// look into your theme code how the posts are inserted, but you can use your own HTML of course
40 42
 			// do you remember? - my example is adapted for Twenty Seventeen theme
41
-			if( true == $search_page ){
43
+			if( true == $search_page ) {
42 44
 				get_template_part( 'templates/loop/content', 'search' );
43 45
 			} else {
44 46
 				get_template_part( 'templates/loop/content', get_post_format() );
Please login to merge, or discard this patch.