Using query_posts
is not advised anymore and in your instance, using it outside of a page template will cause strange results, query_posts
is used for altering the main loop of your site, therefore its advised to use something like WP_Query
instead.
Replace from line 14 of your code:
<?php
//bad: do not use query_posts
global $query_string;
query_posts("{$query_string}&posts_per_page=8");
if ( have_posts() ) while ( have_posts() ) : the_post();
?>
With this,
<?php
//good: use WP_query instead
$paged = get_query_var('paged');
$wp_query = new WP_Query(array('posts_per_page' => 8, 'paged' => $paged));
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
Related Posts:
- PageNavi redirects to 404 when used as archive page
- homepage olderposts link showing page not found
- How to eliminate weird 404 errors in wp-admin?
- Help making my pagination plugin better
- Does WordPress contain “default” anti-SQL injection code that responds with a 404 error?
- How can I force a “404 Not Found” error
- Help With A Reverse Pagination Plugin
- Some plugins adding full server path after url (with custom wp-content folder)
- Why am I sometimes getting a 404 error when I try to update a page with Elementor?
- How to add pagination to wpbakery grid?
- Getting a 404 when trying to load /wp-admin/plugin-install.php
- Show a special message for private page?
- What causes an Unexpected HTTP Error within install plugins?
- Error 404 using wpml plugin
- Custom Post Type Plugin not loading category template and loading 404 instead
- Infinite Scroll for both Index, Category and Archive
- An issue with SEO Ultimate
- Dropdown menu on custom page with product to choose number of products per page
- Admin Panel pagination link styles
- Pagination Broken on Static Pages but Works on Blog Articles
- get 404 when accessing wp-admin/plugin-install.php
- Plugin dropping pagination variable
- how to use in custom single.php template using php?
- How to show only next post pagination link using wp_link_pages()
- Reoccurring 404 Errors on all subpages
- URL parameters causing 404 on home page, but nowhere else
- Some one is trying to hack my website, Need guidance [closed]
- pagination on data fetched using SQL query
- How to apply next/previous classes to LIs for pagination links?
- Replacing global wp_query
- My custom php file keeps 404’ing in WordPress when I call it. What am I missing?
- wp-admin send 404 error
- Which filter/action should I use to serve content for “virtual” files
- Change the number of plugins counted on wp-admin/plugins.php
- Huge number of 404 pages getting spawned
- speed up pagination for huge database
- Pagination not working
- Permalinks and pagination are not working in WordPress with WP e-Commerce plugin
- How to disable Wp-PageNavi at the top of the page
- how to show all posts of each category in pages
- How to Join wp_posts & wp_postmeta table using custom query
- Enable comments pagination only amp page
- How to detect 404 url and make this link underline or change background color?
- why is my wordpress not loading any images?
- All Post WordPress Page Error
- WordPress website dont load CSS, JS and images
- Pagination not working with pagenavi
- Ajax Load More on Hierarchical Categories
- WordPress website giving 404
- Plugin with AJAX on subdomains causes 404 in console
- Getting 404 page not found error while trying to access add new plugin / themes
- get recent 12 days post then random in wordpress
- Wp Pagenavi how to display all results
- Pagination in category
- wp_pagination not displaying at top of page
- 404 Page when emptying spam or deleting a plugin
- Next and Previous Pagination button not displaying in WordPress
- WooCommerce custom query and paging: Not Found error
- Infinite scroll for text in post with url page change
- How to create load more button without a plugin?
- Plugin Icon does not work correctly
- 404 Error on a WordPress Website, Error disappears for a while and again appears
- /wp-admin/plugins.php takes ages to load, and then 404s
- wp-login 404 page not redirecting to homepage [closed]
- Plugin Error – Not Sure Where to Go From Here
- Add pagination to a page with sections
- How to allow customers to input a text as a product variation *and* charge per character?
- woocommerce blank page after clicking add to cart [closed]
- Defined user role to access plugin’s pages
- Plugin Works, but Widget Doesn’t
- Need help getting a certain value out of a multi dimensional array
- Best use adding user generated JS/CSS to a theme with a plugin
- Retrieve data from multiple WordPress sites using PHP script
- Site not displaying correctly when re-directing from root to sub-directory
- How to add wpmode in Flash Embed Code in WordPress Site?
- How to create an uploads subfolder on a multisite setup?
- API Functions to Register and Show WordPress List Tables
- Create Database Tables on Plugin Activation hook
- resizes images on the fly
- Inactive Plugin Files
- How to create a new database table whenever user changes options
- Things that saved lose when logout
- plugins_loaded action is not working properly
- Auto-login from backend
- How to save default values into an option and delete those upon actvation and deactivation in wordpress?
- Plugins don’t show up after renaming plugins folder
- Am I correctly adding styles to plugin?
- Creating a user ‘add custom field’ section
- WordPress Settings – Custom Button actions
- Theme Load Error
- How to hook into search results template or query?
- How to prevent query strings persisting on certain page templates
- How to Add Jquery FullCalendar in wp plugin in admin
- How can I insert a record into a custom table from my custom form in my custom admin page?
- Javascript not working
- how to create table during plugin installation in side a class
- Conditional required fields for WordPress Contact Form 7
- Modify a plugin’s content
- Modify php code from plugin
- Which WordPress version to use for improved plugin compatibility? [closed]