1

Can I change pages with Ajax + Wordpress without reloading?

Only articles related to dynamic post display or AJAX pagination are available on the web.

Where can I find out about the use of AJAX in 'wp_nav_menu "

Here is my inspiration: (see their navigatio) LINK

7
  • 1
    You can use js pushState for that Commented Aug 13, 2021 at 16:04
  • @Buttered_Toast Will it help to create something like this? link - see their navigation - changes the link without reloading
    – Simon
    Commented Aug 13, 2021 at 16:08
  • You want the site content to change as well? without reloading the page? am I correct? Commented Aug 13, 2021 at 16:10
  • @Buttered_Toast Yes Sir
    – Simon
    Commented Aug 13, 2021 at 16:12
  • Wordpress alone doesn't have the tools to do that, you will need to use angular or react to achieve that. You can use ajax to update sections of your site not whole pages is a big mess with ajax alone, you need to update css and js and update a whole lot. WordPress is not built for that. Commented Aug 13, 2021 at 16:16

1 Answer 1

2

The site you linked to isn't updating the nav menu with AJAX, rather, when you click a link they load the target via JS then swap the entire page for the new page.

A little bit of trickery with pushState ensures the URL in the address bar changes and back/forward is preserved. Take a look at the term PJAX, there are JS libraries that implement it, and it may be a more useful search term.

Otherwise your options are limited. If you're building a SPA, you will want to construct your menu and use browser history/current URL to figure out which element to style

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.