Skip Navigation

[Resolved] Insert a function into a Views

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to sort a View using a rating provided by the WP-Postratings plugin.

Solution: The rating is available as a postmeta value, which can be operated upon by Views sorting.

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by Pat 4 years ago.

Assisted by: Christian Cox.

Author
Posts
#1842247

Pat

Hello,

I have a site with Toolset and have created a specific postype "Oeuvre"
I want to offer the users the ability to rate the different "Oeuvers". For this, I'm using the WP-PostRatings plugin.
In my "Oeuvre" postype template, I have inserted a shortcode that allows to rate. This working fine.
Now, I need to create a specific page in which I will display the most rated "Oeuvre"
I the plugin documentation, they indicate that I can use this code :

<?php if (function_exists('get_lowest_rated')): ?>
    <ul>
        <?php get_lowest_rated(); ?>
    </ul>
<?php endif; ?>

How can I use this function to manage a Views of my postype "Oeuvre" ?
Regards
Pat

#1842295

Hi, can you tell me a bit more? I would like to know more about how you would like to manage a View with this function. Are you saying you would like to display a View of Oeuvre posts, sorted by rating? Or are you saying you would like to insert this function inside a View of Ouevre posts somehow?

If you would like to sort a View of Oeuvre posts by rating from this plugin, I would need to know more technical information about how the rating is stored for each post. If the rating is stored in a postmeta value for each post, I may be able to show you how to access that value for sorting.

If you would like to insert this function inside a View of Oeuvre posts, then you must create a custom shortcode that calls this function and returns the correct results. Then place the custom shortcode inside the View, either inside or outside the loop depending on how many times you want to display the results.

#1842469

Pat

Hi Christian,

Thanks for your quick answer.
In fact, the rating is stored as a custom field in the postmeta table and I can have the ability to use this custom field as a Toolset Views sorting parameter (this custom field appears in the list proposed by Toolset).
So, my issue is solved now. Sorry to have bother you before having had a deeper look at all the possibilities !!!

Regards
Pat