Unable to load second page for search results

This topic has 3 replies, 2 voices, and was last updated 1 months ago ago by Andrew Mitchell

  • Avatar: avenoir
    avenoir
    Participant
    November 5, 2025 at 04:30

    Good day,

    The search function is unable to display results after page one. For example the search results for term “sofa” should return 100 results, however I can only see results for first page, when I click page 2 or onwards, is shows error “That Page Can’t Be Found”. I am not sure if the error is related to the recent patches or Xstore Core plugin update as it started to happen recently.

    Please refer to attached images. I believe it is caused by the “#038;” part of the URL, example “https://arturo.com.my/page/2/?product_cat=0#038;s=Sofa&et_search=true&post_type=product”

    Kindly advise and assist on a fix. The error occurs for “pagination” or “load more” or “infinite scroll” navigation.

    Please, contact administrator
    for this information.
    Files is visible for topic creator and
    support staff only.
    2 Answers
    Avatar: avenoir
    avenoir
    Participant
    November 5, 2025 at 05:01

    UPDATE
    I have added the below php code snippet into my mu-plugins folder to fix the issue. However, is there a permanent fix from 8theme developer side? Would prefer to not add any custom code php code on my side.

    <?php
    /**
     * Plugin Name: Arturo – Fix Search Pagination (&#038; / #038;) for WooCommerce
     * Description: Normalizes pagination/querystring ampersands so page 2+ of product searches don’t 404.
     * Version: 1.0
     */
    
    /**
     * Normalize URLs generated by WordPress pagination helpers.
     */
    function arturo_normalize_ampersands($value) {
        $replacer = function($url) {
            // Replace both the entity and the broken fragment with a real '&'
            $url = str_replace(array('&#038;', '#038;'), '&', $url);
            // Guard: fix cases like "?...??#038;" or "?...&#038;#038;"
            $url = preg_replace('/(\?[^#]*)#038;/', '$1&', $url);
            return $url;
        };
    
        if (is_array($value)) {
            foreach ($value as &$v) { $v = $replacer($v); }
            return $value;
        }
        return $replacer($value);
    }
    add_filter('get_pagenum_link', 'arturo_normalize_ampersands', 99);
    add_filter('paginate_links',    'arturo_normalize_ampersands', 99);
    
    /**
     * Front-end safety net:
     * – Fix any bad links produced/modified by AJAX or infinite scroll
     * – Keep fixing as new nodes are injected
     */
    add_action('wp_footer', function () { ?>
    <script>
    (function () {
      function fixLinks(root) {
        var as = (root||document).querySelectorAll('a[href*="#038;"]');
        for (var i = 0; i < as.length; i++) {
          var href = as[i].getAttribute('href');
          if (!href) continue;
          as[i].setAttribute('href', href.replace(/#038;/g, '&'));
        }
      }
      // initial pass
      fixLinks(document);
      // keep fixing as infinite scroll / AJAX adds more nodes
      new MutationObserver(function (muts) {
        for (var m of muts) {
          for (var n of m.addedNodes) {
            if (n.nodeType === 1) fixLinks(n);
          }
        }
      }).observe(document.body, { childList: true, subtree: true });
    })();
    </script>
    <?php }, 100);
    
    /**
     * (Optional) Prevent over-eager canonical redirects from interfering on search pages.
     */
    add_filter('redirect_canonical', function ($redirect_url, $requested) {
        if (is_search()) return false;
        return $redirect_url;
    }, 10, 2);
    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    November 5, 2025 at 09:01

    Hello, avenoir,

    Thank you for your update and for sharing the custom PHP snippet you have implemented to resolve the search pagination issue. We appreciate your effort in identifying a temporary solution.

    Please note that our development team is aware of this matter and is currently reviewing it to provide a permanent fix in one of the upcoming theme updates. We recommend keeping your theme and core plugins up to date to ensure you receive the latest improvements and fixes as soon as they are released.

    In the meantime, your temporary solution can be safely used until the official update becomes available.

    Best Regards,
    8Theme’s Team

  • Viewing 3 results - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.