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
.
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:
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.
Leave a Reply