Make only CONTENT of wordpress theme refresh

I want to make a wordpress site that refreshes only the content/post part and not the header, navigation, footer or the sidebar.
Is this possible? If yes then how?

Related posts

Leave a Reply

2 comments

  1. If you want most of the elements to remain in place you are not refreshing necessarily. What you would want to do is an AJAX request to retrieve the new information for the_content and update the DOM with JavaScript.

    You would need a function that intercepts the click event for links, handles the AJAX, and then returns false to prevent navigating away from the page.

  2. What you try to achieve is technically possible, however your wordpress theme must support that. You need to use AJAX for it and your theme needs to provide server endpoints for the type of content that is going to be requested.

    This can be done by providing fragment templates inside your theme which only return the fragment in question (e.g. content column, menu). However depending on your site’s layout this might not be always possible, e.g. if the layout changes from one page to another.

    A possible workaround is to request the new page via AJAX and only replace the parts inside the DOM that are changed.

    In any case you need to register an AJAX PHP callback function within wordpressCodex.