Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #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?

    #494818

    Hey 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!
    Andy

    #540501

    Thanks 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.

    #540514

    And now it is mysteriously not working. I don’t have the option to choose the order. It was working, now it’s not.

    #542827

    Hi!

    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,
    Ismael

    #1141100

    This 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, 1 month ago by mikehartrich.
    #1141808

    Hi,

    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,
    Ismael

    #1144046

    Hi 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
    #1144821

    Hi,

    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,
    Ismael

    #1144871

    Hi Ismael,

    The site is on WPXHosting.

    #1145094

    Hi mikehartrich,

    Please check with your hosting provider if they disable such a function.

    Best regards,
    Victoria

    #1172036

    I 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?

    #1172308

    Hi,

    Unfortunately no, as we do not have any other way to debug this

    Best regards,
    Basilis

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.