How to order posts in Avada Post cards element by a custom field2 min read

Context

In a previous post, I wrote about customizing the Avada Post Cards element to fetch posts from the database based on a custom field value. It’s good to mention it once more that this feature was added to Avada later on, and it’s now shipped by default in all new versions of Avada starting from June 2022

Oderby options Avada Post Cards Element

I made something similar this time because I needed it, and it was not included in Avada. I’m using Avada in combination with Admin Pods, where I have a custom post type (CPT). This CPT has a custom field calledactivity_date, and on the front-end (archive layout) for this CPT, I need to order those CPTs based on the value of the custom field. Unfortunately, within the Post Cards element in Avada, you can only order the fetched (custom) posts by one of the following attributes: date,title, name, author, id, comment_count, modified, rand, price, popularity,rating, event_date .

Check the screenshot below; the default value is to order by Date .

Solution

Oderby custom field options Avada Post Cards Element by Peshmerge Morad

To solve this problem, I had to edit the file fusion-post-cards.php in /wp-content/plugins/fusion-builder/shortcodes/fusion-post-cards.php. The adjustments I have made in the file enable anyone who uses the Avada Pos Cards element to order fetched posts by a custom field in the (custom) posts.Β  Check the screenshot below:

As you can see on the screenshot, I have entered the custom field activity_date in the field Custom Field Name . Then I had to specify the Custom field type this is very important to be selected correctly. In my case, since the custom field is a date field, I had to select Date. Make sure to choose a type that matches the custom field’s content. The default value is String. To read more about the types of WordPress, please visit the WordPress’s Developer Resources via this link.

Again, I will reach out to the Avada support team and ask them to incorporate my change in Avada!

Update 18/07/2023

Avada incorporated my code changes into their code base. If you check the Avada changelog, you’ll see that Version 7.11 – June 19th, 2023  included this new feature:
- NEW: Added option to order Post Cards by custom sorting order and by custom field. This means you don’t need my file changes anymore since it’s already there from version 7.11.

18 responses

  1. Hi Peshmerge β€” I just stumbled on your blog, and I’m loving it. I’m a longtime user of Avada and a big enough proponent of the theme that I put as many clients on it as I can. That said, you have plenty of interesting content beyond Avada too β€” really awesome stuff.

    In this specific case, I’m wondering if you could help me with the following:

    – Do you ever share the code modifications you made, or do you leave that to the reader and use this blog merely to let people know it’s possible (and the template to account for)?

    – As far as I know, you can’t create a child theme override for the fusion-post-cards.php file, correct? So, at present, are you just reincorporating your adjustments with every new theme update that Avada pushes out?

    Thanks man!

    – Jay

    1. Hi Jay,

      Thanks for your kind words!
      I would like to share the code with everyone because I believe many people out there need what I have achieved. However, considering the commercial nature of Avada and the license, I can’t share the code here or on GitHub!

      I have contacted Avada support, offered them my modification, and asked if they want to incorporate it in the upcoming release(s)! They were very welcoming but didn’t give a specific date for that!

      And indeed, since you can’t override the file, I copy and paste the modification after each update πŸ™ I know it’s not a sustainable solution, but I have no choice!

      If you want this specific feature, I’ll be more than happy to share the code with you, but I need some kind of proof (screenshot or whatsoever) that you have a valid Avada license to avoid any problems with Avada due to sharing their code with others!

      Cheers,
      Peshmerge

      1. Thanks Peshmerge!

        I’d be happy to provide proof by email, or by whatever means you’d prefer β€” when convenient, just let me know how you’d like to go about it πŸ™‚

        (and thanks!)

        1. Hi Jay,

          Just hit me at p{dot}morad{at}hotmail{dot}com

          Cheers πŸ™‚

  2. I’ve been looking for this for months and have tried countless times to come up with working code myself to accomplish this. Please make this code available, it’s the one thing missing in Avada!

    1. Hi Jelle,

      Thanks for your comment! Please email proof you have a valid license, and I will be more than happy to send you the modifications!

      Cheers,
      Peshmerge

  3. Sam Henderson Avatar
    Sam Henderson

    Hey, could you please send me the source code for this? This is an absolute life-saver.

    1. Hey Sam,

      Sure πŸ™‚

      Cheers,
      Peshmerge

      1. Bosco Avatar

        I would be very interested in the source code as well since it’s a major problem for me right now. Thank you in advance

        1. Hi Bosco, no problem!
          Please send me by email a proof that you have a valid license for Avada, and I will be happy to send you the code!

          Cheers,
          Peshmerge

  4. Dear Peshmerge, I found your post on the web and would be awesome if you could share this code with me.

    This feature I think is a must have and I hope that Avada team will add it asap.

    Regards Marco

    1. Hi Marco,

      Thanks for your comment!

      I will be happy to share it with you! I kindly ask you to provide evidence of a valid Avada license per email! Once I receive it, I send you the file!

      And yeah, I will contact Avada support again and ask them to incorporate my code modifications in their code base!

      Cheers,
      Peshmerge

  5. Hi there! I just sent you an email about getting a copy of the code to implement this, thanks!

    1. Hi Cam,

      I will do!

  6. Is it possible to select a post status for the post cards as well? I’d like to create a carousel that only features scheduled posts to give users a “Coming Soon” banner at the top

    1. Hi Chris, can you elaborate a bit more? What exactly do you want to do?

  7. Danny Portal Avatar
    Danny Portal

    i wish they would implement some sort of new post badge with conditional data like only apply it on posts the are 10 days old or younger…. do you know of anything that does that ?

    1. Hi Danny,

      It’s not that difficult. It depends on what you have? Do you mean doing that when fetching WP Posts? or CPTs? Can you provide more context/details?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.