The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript [Solved] Jquery switch view modes without refresh Re: [Solved] Jquery switch view modes without refresh


Hey Thierry,

PHP code is executed once a page is loaded, you’re not going to be able to include php loops within javascript.

What you could do is execute both loops within the page. So the one list will be ontop of the other list. You could then wrap both lists in a div, for example:

Click here to switch between list and grid

// grid wordpress loop here

// list wordpress loop here

#list{display: none;}

$('#grid, #list').toggle();

By clicking on the anchor link, you will be hiding the grid and showing the list. When you click again, you will show the grid and hide the list – Which seems to be what you were looking for.