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
- Woocommerce Add Variation Product to Cart from custom link [closed]
- Plugin Development: WPMU or WP?
- Plugin to restrict non-admin user to existing tags
- Need a function for changing saved post_date or post_date_gmt to relative time in wordpress
- Two embedded gallery in one post
- Multisite: Activate plugin for subsites only?
- How to filter content post only on save
- Capitalize All Titles and Headlines in Chicago Style
- Plugin custom Action Hook not working
- Find the URL of the current plugin directory
- Is there a hook that is called only once after plugin bulk update process is completed?
- How to send mail to subscribers using wp_mail
- Doubt using $wpbd->get_col for a single column
- My Calendar Plugin – add output directly in template file
- Woocommerce API HTTP Response 401
- Time consuming callbacks in customizer
- “Micro-Site” Options
- Output content to the_content before a plugin does
- Overriding Parent Theme… will cause plugins failure?
- How to extract data from ‘edit my profile’ page in WordPress?
- Need to show featured service boxes on my company website
- The correct way to handle GET or POST requests in the admin panel
- How to find the Registration page
- Role based permission edit for plugins
- Rename existing cpt and taxonomy with new textdomain
- Getting infinite scrolling working on my custom template
- Plugins custom table not being created on activation
- Facing Problem with admin-ajax.php URL – Getting 404 with AJAX call
- Use buddypress function outside of plugin
- How can I disable access to plugin settings in wp admin for other roles
- Searchable Semi Random Number Generator on User Profiles
- Save Post Permalink In .txt File
- Renamed plugin folder and when I changed back nothing was activated
- Why haven’t I see plugins using get_file_data to handle retrieving plugin version?
- How often should I execute add_filter and function declaration in Code Snippets?
- Ad Management Plug that can be used on a membership site
- How do I remove the filter from the orders and add custom status in Dokan?