I have a masonry portfolio on my homepage, in which portfolio items are ordered by date of creation (the latest are the highest). I'd like portfolio items to be displayed in a random order, so that it is ordered differently each time I refresh my homepage.
Could you tell me if there's an option for that in the Laborator settings, or tell me what code I can paste in my PHP or JS to set this up ?
For my understanding: You have portfolio items on your homepage as an "eyecatcher" and on your site a normal portfolio page too (in which the items are ordered normally). On the homepage there should be a "random part" of your portfolio items? Am i right?
Sorry, I could've explained it better haha Here is what my homepage looks like: it's both the homepage and the portfolio page. I just want the items to be displayed in a random order.
If your homepage / landing page is made with WP bakery pagebuilder and NOT the portfolio post type archive page then you could change the query in the Portfolio AddOn, if the page is made with the portfolio page template then you have to tweak it by your functions.php and add:
This should work - untested. I do it similar but i track the shown items and show only "unviewed" items on next reload. So i had to shorten my code a lot.
You are right: is_home() only work for blog page as home. Sorry - i tried to answer quickly - but with the slug is more safe too. Nevertheless your using of is_home() was wrong. But for your case the slug is the right solution.
If you have a lot of portfolio items, there exist the possibility to "track" the shown items and to show new ones on the next reload. But this is a little bit more tricky but works very nice. I use this on many positions on my new page.
To make your portfolio on your homepage to show different projects every time you enter the page you just need to navigate to Portfolio Items element setting and change the Order by > Random.
I was surprised not to find a built-in option for that, turns out I just didn't search enough 😅 As I used the Portfolio page template, the "Custom Query" button is in Parameters and Options, but that's the only difference.
Hello,
I have a masonry portfolio on my homepage, in which portfolio items are ordered by date of creation (the latest are the highest). I'd like portfolio items to be displayed in a random order, so that it is ordered differently each time I refresh my homepage.
Could you tell me if there's an option for that in the Laborator settings, or tell me what code I can paste in my PHP or JS to set this up ?
Thanks in advance, have a nice day :)
For my understanding: You have portfolio items on your homepage as an "eyecatcher" and on your site a normal portfolio page too (in which the items are ordered normally). On the homepage there should be a "random part" of your portfolio items? Am i right?
Here is what my homepage looks like: it's both the homepage and the portfolio page. I just want the items to be displayed in a random order.
Thanks!
If your homepage / landing page is made with WP bakery pagebuilder and NOT the portfolio post type archive page then you could change the query in the Portfolio AddOn, if the page is made with the portfolio page template then you have to tweak it by your functions.php and add:
This should work - untested. I do it similar but i track the shown items and show only "unviewed" items on next reload. So i had to shorten my code a lot.
Try it und perhaps give a feedback.
Thank you for your answer!
To be honest, my skills don't go beyond using a theme template and pasting custom CSS.
I used the "Freelancer" child theme so I think it is made with the portfolio page template you mentioned.
I tried to put your code in the functions.php and it says there is a syntax error with the ";" on line 53.
Could you tell me what I did wrong?
Thanks in advance :)
sorry i forgot one closing bracket:
and i'am only a user too - only for your information.
Regards André
The "is_home" didn't work for me but the page slug did!!
You helped me to get rid of the biggest issue I had with my website, I'm really grateful.
Thank you very much André, have a nice day :)
You are right: is_home() only work for blog page as home. Sorry - i tried to answer quickly - but with the slug is more safe too. Nevertheless your using of is_home() was wrong. But for your case the slug is the right solution.
If you have a lot of portfolio items, there exist the possibility to "track" the shown items and to show new ones on the next reload. But this is a little bit more tricky but works very nice. I use this on many positions on my new page.
Hi sofiane,
To make your portfolio on your homepage to show different projects every time you enter the page you just need to navigate to Portfolio Items element setting and change the Order by > Random.
See video: https://d.pr/v/UcZ9bc
Have a nice day!
P.S. If you use a caching plugin this will not work as it should because caching plugins cache your pages and don't refresh them on each page load.
Hi Ylli,
I was surprised not to find a built-in option for that, turns out I just didn't search enough 😅
As I used the Portfolio page template, the "Custom Query" button is in Parameters and Options, but that's the only difference.
Thank you for your time, have a nice day as well!