PHP Code Snippets/Functions Reusable Custom Blocks

Custom number of entry selection

<?php$args = array( ‘post_type’ => ‘sample’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1,);$query = new WP_Query($args);$total_posts = $query->found_posts;$numbers = array(1, 2, 20);if ($total_posts > 0) { $numbers = range(1, min(20, $total_posts));}?><label for=”post-number”>Show</label><select name=”post-number” id=”post-number” class=”post-number-select”> <option value=”-1″ selected>All</option> <?php foreach ($numbers as $number) : ?> <option value=”<?= $number; ?>”><?= $number; ?></option> <?php endforeach; ?></select><label>entries</label> $(‘.post-number-select’).on(‘change’, function […]