Translating a pager string

You are doing it wrong You should translate the HTML string, not the function When passing strings into functions, like what you are doing, you should use __() which returns the translated string. _e() would echo the string and you would get the raw text and the modified text on output Example of correct usage: … Read more

wordpress custom search page pagination returns 404

You should use pre_get_post action to alter the search query. It is much better approach and you will avoid unnecesary queries (actually, with your code, WordPress already performed the database query for the current request but you discard it and perform a new database query). add_action( ‘pre_get_posts’, ‘custom_search_query’ ); function custom_search_query( $query ) { // … Read more

How to remove /page/2/ from home page?

If the front page is set to display posts then the query for those posts will run regardless of wether your theme shows these posts or not. That’s why you’re getting pagination with no posts. You can test this by temporarily removing your themes front-page.php (or whatever it is). You should see all your posts … Read more

Pagination for search results of custom post type [duplicate]

You need to set your paged arg in your $args array: $listing_args = array( ‘post_type’ => ‘business’, ‘posts_per_page’ => 10, ‘meta_key’ => ‘listing_num’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘offset’ => ($paged -1) * 10, ‘paged’ => $paged, // <- tell the query what page we are on. ‘tax_query’ => ……etc ); And then use … Read more

Pagination in html table is not working

You should get total and result array separately. Total is to create the page numbers and result array will give you limited data for each pages. Refer the below code. if (isset($_POST[‘list_position’]) && $_POST[‘list_position’] != ‘Select by Position’){ $list_position= $_POST[‘list_position’]; $totalPosition= $wpdb->get_var(“SELECT count(id) FROM resume_databank WHERE position= ‘” . $list_position . “‘ ORDER BY position … Read more

How to limit page pagination… again

I was lucky, the theme used it’s own function, so it was easy to override. Inspired by worpdress native get_the_posts_navigation (wp-includes/link-template.php) here is what I end up using: function my_get_the_posts_navigation( $args = array() ) { $limit = 5; $navigation = ”; // Don’t print empty markup if there’s only one page. if ( $GLOBALS[‘wp_query’]->max_num_pages > … Read more

Problem with older entries in homepage

Why don’t you try with default query and use like this if ( get_query_var(‘paged’) ) { $paged = get_query_var(‘paged’); } elseif ( get_query_var(‘page’) ) { $paged = get_query_var(‘page’); } else { $paged = 1; } $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 6, ‘paged’ => $paged, ); query_posts($args); while (have_posts()): the_post(); // do something … Read more

How to custom post navigation

You could try combining these: Buttons next_posts_link( ‘Prev’ ); previous_posts_link( ‘Next’ ); Current page echo (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; Total pages wp_count_posts(); In HTML <?php next_posts_link( ‘Prev’ ); ?> <?php echo (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; ?> <span> of </span> <?php echo wp_count_posts(); ?> <?php next_posts_link( ‘Prev’ ); ?>

error code: 521