Custom admin page pagination permissions error

I fixed this using another post – Pagination Error on Admin (You do not have sufficient permissions) Basically I needed to changed the $paged argument to $paged = isset( $_REQUEST[‘paged’]) ? max( 1, ( int ) $_REQUEST[‘paged’] ) : 1; and the $pl_args argument to $pl_args[‘base’] = admin_url( ‘admin.php?page=cpd-admin-page&paged=%_%’ );

Style wp_link_pages as a select drop down list

Here’s one way to achieve that is by constructing the <option> tags with the wp_link_pages_link filter: add_filter( ‘wp_link_pages_link’, function( $link, $i ) { return sprintf( ‘<option value=”%d” %s>%d</option>’, $i, selected( $i, get_query_var( ‘page’, 1 ), 0 ), $i ); }, 10, 2 ); and then the <form> and <select> tags with the wp_link_pages filter: add_filter( … Read more

Pagination issue with tag.php

Never re-do the main query. Hook into pre_get_posts and change it. The following needs to go in your functions.php (putting in the template will mean it runs too late): add_action( ‘pre_get_posts’, function ( $wp_query ) { if ( $wp_query->is_main_query() && $wp_query->is_tag() ) { $wp_query->set( ‘posts_per_page’, 20 ); $wp_query->set( ‘post_type’, [ ‘pavilion’, ‘post’, ‘catalog’, ‘tenders’, ‘services’, … Read more

404 Page Not Found on /Page/2/ on Tag Page

Nevermind. I forgot to add this in my functions.php. I will leave the answer here so it may help others. //Tag pagination pages function wpd_custom_types_on_tag_archives( $query ){ if( $query->is_tag() && $query->is_main_query() ){ $query->set( ‘post_type’, array( ‘portal’ ) ); } } add_action( ‘pre_get_posts’, ‘wpd_custom_types_on_tag_archives’ );

speed up pagination for huge database

The article on wordpress is interesting and true but I’m not sure what’s it’s purpose. The provided code is for cases when you want to do some action for every post ; it doesn’t help with the pagination on site directly. You may try https://wpartisan.me/tutorials/wordpress-database-queries-speed-sql_calc_found_rows instead, but with million posts, even better would be to … Read more

error code: 521