Orderby post__in Not Working Correctly?

If you look at the source of the Ajax Load More plugin, you can see a number of filters you can use to modify the query. You’ll likely want to use the alm_modify_query_args filter like so: $in_array = [ 115, 123, 66, 64 ]; add_filter( ‘alm_modify_query_args’, function( $args ) use ( $in_array ) { $args[ … Read more

number of posts with “Load More”

You can get the (current) displaying posts number from offset number. As it’s an ajax load more for wp post, it should has the offset numbers. So, you can display the number like this Javascript var offset = 4; return $.ajax({ url: ajaxurl, type: “POST”, data: data, success: function(returnData) { // diplay offset number in … Read more

Let user select the number of posts shown per page jquery error

A simple fix would be to change the query name; i.e. from page to pageVal. <script> jQuery(document).ready(function( $ ) { $(‘.page-select’).change(function(){ var checkIndex = ( window.location.href || ” ).indexOf(‘?’); if( checkIndex > -1 ){ var Link = window.location.href.substr(0, checkIndex-1); $(location).attr(‘href’, Link+’?pageVal=”+$(“.page-select’).val()); } else { $(location).attr(‘href’, window.location.href+’?pageVal=”+$(“.page-select’).val()); } }); }); </script> But I’d use this..: <script> … Read more

Target a specific page/template in jQuery

Approach 1 Use the body class. all templates will have a class representing them. ie: body.archive, body.single, body.home, etc. It will even have specific tax/post type classes for more granular control. Wrap your js function in something that checks for that body class. The following should do the trick: jQuery if ( $( ‘body’ ).first().hasClass( … Read more

include javascript Multiple files in wordpress through script.js

Open console ( right click -> inspect – Console ) and read what is the error, you probably didn’t enqueue jQuery You should enqueue scripts from functions.php ( best practice ) function theme_scripts() { wp_enqueue_script( ‘jquery’ ); wp_enqueue_script( ‘script’, get_template_directory_uri() . ‘/script.js’, array(), false, true ); } add_action( ‘wp_enqueue_scripts’, ‘theme_scripts’ );