Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

GrahamUK33

Privileged
  • Joined

  • Last visited

  1. Thanks for having a look, I have just emailed it over to you.
  2. I have tried that, it is still not working. I am at a complete loss at what is going on with this code.
  3. Now the pagination on author.php has stopped working, I am so frustrated with this...
  4. What I have done is taken out the following code. This code helps with 404 Errors on Pagination - https://www.bamboomanchester.uk/fix-404-errors-wordpress-pagination/ functions.php function bamboo_request($query_string ) { if( isset( $query_string['page'] ) ) { if( ''!=$query_string['page'] ) { if( isset( $query_string['name'] ) ) { unset( $query_string['name'] ); } } } return $query_string; } add_filter('request', 'bamboo_request'); add_action('pre_get_posts','bamboo_pre_get_posts'); function bamboo_pre_get_posts( $query ) { if( $query->is_main_query() && !$query->is_feed() && !is_admin() ) { $query->set( 'paged', str_replace( '/', '', get_query_var( 'page' ) ) ); } } What I have now, is that the pagination on search.php and author.php now works as it should, but it doesn't work on category.php without the code above in functions.php. category.php <?php /* viewing posts by current category */ get_header(); ?> <div class="wrapper-main"> <div class="wrapper-inner-main"> <!-- display category --> <div class="category-title"> <h1><?php single_cat_title(); ?></h1> </div> <div class="category-description"> <?php the_archive_description(); ?> </div> <!-- display posts --> <?php $currCat = get_category(get_query_var('cat')); $cat_name = $currCat->name; $cat_id = get_cat_ID( $cat_name ); ?> <!-- the loop --> <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query('showposts=10&paged='.$paged.'&cat='.$cat_id); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <!-- category posts --> <div class="showposts-by-category"> <div class="showposts-single-post-by-category"> <a href="<?php the_permalink() ?>"> <div class="showposts-image-by-category"> <?php the_post_thumbnail('thumbnail'); ?> </div> <div class="showposts-category-by-category"> <?php the_category(); ?> </div> <div class="showposts-title-by-category"> <?php the_title(); ?> </div> <div class="showposts-excerpt-by-category"> <?php the_excerpt(); ?> </div> </a> </div> </div> <!-- end the loop --> <?php endwhile; ?> <!-- pagination function --> <div class="post-navigation-wrapper"> <div class="post-navigation button-link"> <?php previous_posts_link( 'Back' ); ?> </div> <div class="post-navigation button-link"> <?php next_posts_link( 'Next' ); ?> </div> </div> </div> </div> <?php get_footer(); ?> @fisicx @Jack is there something you can see that is stopping the pagination on category.php without having the Error 404 code in functions.php ?
  5. I don't have any plugins, it is just a basic theme while I develop it.
  6. Using the 2020 theme: Categories: first page shows, then pagination does not work - this works fine in my theme. Author: first page shows, and pagination also works - this does not work in my theme. Search: first page shows, and pagination also works - this does not work in my theme. The results are the opposite to what I get with my theme... strange!
  7. I have used the above code in my search.php and re-saved the permalinks. The search does work when searching for a particular article. When searching for a term that will bring up a number of articles, the pagination at the bottom appears (once highlighted), but once clicked on it doesn't return another page. As far as the URLs: When I do a search, I get http://british-history.co.uk/?s=Battle Once clicked on Next, I get http://british-history.co.uk/?paged=2&s=Battle My Categories work fine, and to compare the URLs I get the following: First page http://british-history.co.uk/napoleonic Once clicked on the Next button http://british-history.co.uk/napoleonic/page/2 Then when clicked on the Back button I go back to the first page http://british-history.co.uk/napoleonic This is what makes this problem so puzzling.
  8. Thanks for having another look at this @Jack. I will give it another go tomorrow, and let you know how I get on.
  9. Yeah, I think you are right, but I don't know what it could be. category.php works fine http://british-history.co.uk/napoleonic which is what makes this so puzzling. Its just a problem with search.php and author.php that the Pagination does not work.
  10. I have been trying different code, and adding it to function.php but that has not worked. I have put in the code above and I am unfortunately still getting the same problem. From - http://british-history.co.uk/?s=Battle To - http://british-history.co.uk/page/2?s=Battle
  11. After adding the code above, it still does not go page 2, but the URL changes: From - http://british-history.co.uk/?s=Battle To - http://british-history.co.uk/page/2?s=Battle
  12. Unfortunately I still have the same problem of the results appearing, but the 'next' button not forwarding to page 2.
  13. This is the code I have. search.php <?php /* search results. */ get_header(); ?> <div class="wrapper-main"> <div class="wrapper-inner-main"> <!-- the loop --> <?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : '1'; $s=get_search_query(); $args = array( 's' =>$s, 'paged' => $paged ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : ?> <?php while (have_posts()) : the_post(); ?> <!-- posts --> <div class="showposts-by-category"> <div class="showposts-single-post-by-category"> <a href="<?php the_permalink() ?>"> <div class="showposts-image-by-category"> <?php the_post_thumbnail('thumbnail'); ?> </div> <div class="showposts-category-by-category"> <?php the_category(); ?> </div> <div class="showposts-title-by-category"> <?php the_title(); ?> </div> <div class="showposts-excerpt-by-category"> <?php the_excerpt(); ?> </div> </a> </div> </div> <?php endwhile; ?> <!-- pagination function --> <div class="post-navigation-wrapper"> <div class="post-navigation button-link"> <?php previous_posts_link( 'Back' ); ?> </div> <div class="post-navigation button-link"> <?php next_posts_link( 'Next' ); ?> </div> </div> <?php else : ?> <h1>Nothing to see here</h1> <?php endif; ?> </div> </div> <?php get_footer(); ?> I also found the following that may fix the pagination issue, but not sure where to put it in the above code: https://codex.wordpress.org/Creating_a_Search_Page Preserving Search Page Results and Pagination Search results and Pagination may stop working when applying customization to the search template. To avoid these issues the first thing any developer needs to do is add the following code to the start of their Search template to ensure that the original WordPress query is preserved. To customize the query append additional arguments to (array) $search_query. Execute the $search_query through a new $wp_query object, more information on the WP_Query object can be found at WP_Query. <?php global $query_string; wp_parse_str( $query_string, $search_query ); $search = new WP_Query( $search_query ); ?>
  14. Thanks for the code @fisicx The code brings up 10 post results, but the 'next' button does not show page 2. The URL changes though: http://british-history.co.uk/?s=Battle - shows the first 10 search results. http://british-history.co.uk/page/2?s=Battle - once clicked on the 'next' button.
  15. I think the problem if I am honest is that my understanding of PHP is close to zero. I can see the categories results working fine with the buttons below, and all I am trying to do is replicate that in the search results. I am using the same pagination code at the bottom, along with the same code for the page, its just not working.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.