I think your approach is correct but you’re running into the “posts_per_page” problem.
In your query, use ‘posts_per_page=-1’ to return all posts (assuming that’s what you want). I’m guessing your website is currently set to show 12 posts per page in the settings->reading area.
http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters
Related Posts:
- How to fix “Headers already sent” error in PHP
- What are PHP extensions and libraries WP needs and/or uses?
- How to check if feed URL was requested?
- the_author_meta() vs get_the_author_meta()
- Displaying a WooCommerce product via PHP
- problem with ajax and the path to the php page
- Enqueue Javascript Correctly for 3.5
- Does wordpress allow me to add a php file to the root directory to execute custom scripts?
- Targeting single page with JS
- How to Explode a Textarea Field and Echo each line separately, wrapped with HTML
- Remove General Tab and Plugin Tab in Settings in Woocommerce
- WooCommerce – Display variation custom field value [closed]
- Include a Gutenberg Block in a PHP file
- do not show web page section when using advanced custom fields pro
- How to slow down server response
- Click loads template via ajax
- Why isn’t the canonical link element used for all pages?
- Featured image fallback link to permalink
- Facebook “like” open graph meta in header.php
- Working with a modified WordPress & Theme and updating WordPress
- Get all user meta by meta key instead of ID
- Automatically add custom CSS to new posts using a category template
- how can i show only the parents in owl-carousel?
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Use menu link or onClick to set a variable
- How can I reuse the code to capture a param in a URL and place in a value in a hidden form?
- Different Minimum Order Amounts based on Shipping Zone [closed]
- Change “add to cart” button color based on Woocommerce product category [closed]
- Let Users Choose Post Categories
- Create highly customized submenu (possibly using wp_list_pages)
- Display a message if posts dosen’t exist on loop
- $wpdb->wp_users returning empty value for
- WordPress Custom field Colors
- Change WordPress Upload Folder using wp handle upload
- How to correctly add Javascript to this PHP ‘Page Not Found’ Page?
- List taxonomy term slugs within shortcode (do_shortcode)
- get taxonomy thumbnail and use it as a variable in code
- What are the advantages/disadvantages of using jQuery DOM manipulation as opposed to PHP DOM manipulation?
- Why doesn’t add_filter have the option to include a callback for each run?
- Sending a custom form data in email through WP Mail Function
- Force Users To Relogin
- Security updates to 3.3.2
- Fixing Deprecated: get_the_author_lastname
- How to add PHP code in functions.php wordpress
- wordpress frontend editor to add extra css to website
- How to add page numbering with php?
- Apache HTTP Server stops working for only a certain local website
- If user is logged in not working
- How to Make Thumbnail of Post Stay Animated
- Function to call either single post or category
- search and add in wordpress content
- AJAX function running TWICE with WordPress admin-ajax.php
- OOP PHP class extends TwentyTwenty_Customize in Child Theme
- PHP using external anonymous function inside class
- How to make Subdomain work for product_tag?
- Updating Metadata with Shortcode
- How to spell out a word in products/posts?
- How do I add a function to parent theme
- Are there any drawbacks on opening a session_start in functions.php and header.php?
- Log out without confirmation request (nonce)
- Add Pre-Defined Value to Click Counter in WordPress
- Create a WordPress Contact Form to call a POST AWS API Gateway and send user data
- Setting up a cron job to auto update a custom field
- How do you measure the PHP generation time of your WordPress pages?
- Confuse between forms and tables
- How do I properly upgrade WordPress’s PHP within an OpenLiteSpeed GCP instance? [closed]
- WordPress is setting from header wrongly in wp_mail
- How to edit content in WordPress and the Polylang – plugin? – with demosite
- ACF Gallery field images donwload
- Add post title as a link parameter
- Trying to retrieve meta values from three different meta keys and display in rows
- Cannot figure out how to add a read more link to a manual excerpt. Please help
- Help with find a bit of code to move from functions.php
- This occurs when I open admin or front on localhost
- Search only for posts with specific metadata?
- ACF background-color per post in a WordPress loop
- oembed facebook link?
- Trouble with checked() for array of multiple checkboxes
- Is it possible to dupplicate a WordPress post with php?
- How to create a radio button to alt between settings in wp_options table
- I want to use wordpress database in android app using json encode?
- Filtered table in wordpress
- if user is admin display admin link and logout link else display logout only
- site_url() returns with additional backslashes
- How to redirect unattached image attachments
- Adding instant search to wordpress page
- WordPress changing single quotes to double quotes in title and content
- Easier URL to an image
- MySQL database migration to WordPress
- Change order that the menu is generated with wp_list_pages
- Search result page – display values from the result’s metaboxes
- Using variables as href in anchor tags (PHP) [closed]
- Parse error: syntax error, unexpected ‘else’ (T_ELSE) [closed]
- Code working in functions.php but not pluign for gavity forms
- how to display tables via ajax
- Login user into magento using wordpress account
- save array of objects with update_option
- What is the best way to reset the site? Different fails while set up
- Use of undefined constant issue
- Themeco Looper Provider Query String for current user posts [closed]