Cogito ergo sum

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

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 .
Oderby options Avada Post Cards Element

Solution

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:
Oderby custom field options Avada Post Cards Element by Peshmerge Morad
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 according to the content of the custom field. The default value is String. To read more about the types in WordPress, please visit the Developer Resources of WordPress 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.

About the author

Peshmerge Morad

Data Science student and a software engineer whose interests span multiple fields.

18 comments

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

  • 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

    • 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

  • 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!

  • 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

    • 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

  • 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

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

Cogito ergo sum