Tagged: Magazine layout
-
AuthorPosts
-
August 28, 2015 at 6:35 am #494640
Is it possible to have the magazine layout randomize the order of posts that display without creating a child theme? Are there any plugins that work well with Enfold that can do this?
August 28, 2015 at 1:42 pm #494818Hey mikehartrich!
using a child theme is highly recommended. Refer to this: http://kriesi.at/documentation/enfold/how-to-add-an-orderorderby-option-to-the-blogpost-sliderportfoliomasonry-grid-element/
Cheers!
AndyNovember 23, 2015 at 5:39 am #540501Thanks Andy, that code works. I have only just been able to try it as we didn’t want to have to develop a child theme. But I found the Functionality plugin that lets us add code to the functions.php file in a way that it won’t get overridden by Enfold updates.
November 23, 2015 at 6:46 am #540514And now it is mysteriously not working. I don’t have the option to choose the order. It was working, now it’s not.
November 26, 2015 at 4:02 am #542827Hi!
Use this in the functions.php file to randomize the magazine query:
add_filter('avf_magazine_entries_query', 'avf_magazine_entries_custom_query'); function avf_magazine_entries_custom_query ( $query ) { $query['orderby'] = 'rand'; return $query; }
Which plugin are you using?
Regards,
IsmaelSeptember 23, 2019 at 7:46 pm #1141100This issue is happening again, the category listings that we want randomized are in fixed position always the same. The order is newest first instead of random.
This code is in the functions.php file:
function avf_magazine_entries_custom_query ( $query ) { $query['orderby'] = 'rand'; return $query; }
The pages affected are using the Blog element and each page shows a different blog category, with thumbnail and excerpt. We are using a caching plugin, and host’s CDN (which I found out from our host only caches the images). But I have turned every off, cleared the cache, even had them clear the CDN and also try to find out if it could be the CDN or caching plugin (which the host installed). They said they cannot find any reason for this to be happening on their end. There are rules added to the caching plugin that should exclude these pages. Obviously something is not working.
The caching plugin is called W3TC and in the WP Dashboard it is listed under Performance.Update: I have now turned off the caching plugin and deleted the caching folder that was left behind. I have cleared the cache on the CDN and turned it off. Still the page is not randomizing. At least now though you should be able to see what is happening without any of the caching interfering.
Since our host recommends, installed and configured this plugin I checked with them and confirmed that add page exceptions (to not be cached) I put those page URLs into a field called “Never cache the following pages:”. I checked that I had the format of the URLs correct (must start with / and don’t need the domain name, only page).
I think the issue is with Enfold. is this code still valid? Can you take a look and see what is going on?
It’s fine to clear the cache, turn the caching plugin off temporarily.
- This reply was modified 5 years, 2 months ago by mikehartrich.
September 25, 2019 at 1:42 pm #1141808Hi,
Thank you for the update. It’s been a while.
Did you add the actual filter?
add_filter('avf_magazine_entries_query', 'avf_magazine_entries_custom_query');
Best regards,
IsmaelOctober 2, 2019 at 5:41 am #1144046Hi Ismael,
Yes the filter was added too. Sorry it was right beneath the comment so I missed it when I copied the other code. Here is what I actually have:
// Randomize the trade category listings so members appear in random order each time add_filter('avf_magazine_entries_query', 'avf_magazine_entries_custom_query'); function avf_magazine_entries_custom_query ( $query ) { $query['orderby'] = 'rand'; return $query; }
- This reply was modified 5 years, 1 month ago by mikehartrich. Reason: Edited to put the code into a code block so it appears correctly
October 4, 2019 at 3:57 am #1144821Hi,
Thank you for the update.
Did you deploy the site on media temple or wp engine? They have this feature where they turn off “random” sorting in the database by default, because the query becomes performance intensive. Please check this documentation.
// https://wpengine.com/support/about-order-by-rand/
Best regards,
IsmaelOctober 4, 2019 at 6:05 am #1144871Hi Ismael,
The site is on WPXHosting.
October 4, 2019 at 8:50 pm #1145094Hi mikehartrich,
Please check with your hosting provider if they disable such a function.
Best regards,
VictoriaJanuary 10, 2020 at 1:50 am #1172036I asked the host if they disabled ORDER_BY_RAND() in MySQL queries. The support agent went to look into it and said, I can’t help you. They wouldn’t tell me if it was disabled or not! I will try to go back later and see if I can get a different support agent who will help me.
In the meantime I created a phpinfo() to check if that had anything about the function listed, it didn’t. Is there anything else I can do, any piece of code that could tell me if it’s disabled or not?
January 10, 2020 at 11:03 pm #1172308Hi,
Unfortunately no, as we do not have any other way to debug this
Best regards,
Basilis -
AuthorPosts
- You must be logged in to reply to this topic.