Custom WP_Query always respond with 200 status even when no entry
I'm using a custom WP_Query
. The code is something like below:
$portfolio_args = array(
'post_type' = 'portfolio',
'posts_per_page' = 5,
'paged' = get_query_var( 'page' )
);
$portfolio_query = new WP_Query($portfolio_args);
Now, my portfolio post type has 15 entries (thus it is good for 3 pages). I can navigate to all these pages, but the issue is even the pages which does not have any portfolio entry (e.g. /page/4/, /page/5, ...
) loads just fine (i.e. throws 200 in response header), whereas, I'm expecting it to throw a 404 error if the page has not any entry.
Is it the expected behaviour for custom query pagination? If so do I need to force a 404 response header somehow?
Topic paged wp-query pagination 404-error custom-post-types Wordpress
Category Web