Star Ratings output on View

Support MB Views Star Ratings output on View

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #33409
    ChrisChris
    Participant

    I followed this tutorial to add star ratings.
    https://metabox.io/add-star-ratings-to-wordpress-on-backend/

    Works fine so far. Kinda stuck though: how do I get the stars to show up on a view I created?

    tried the following so far:
    <div> {% set field = attribute( post, 'bewertung_-_rating' ) %} {{ field }}</div><div>{{ post.date | date( 'j. F Y' ) }}</div>
    </div>

    #33430
    Long NguyenLong Nguyen
    Moderator

    Hi,

    If you follow the tutorial to create the rating field, you can click on the button Insert Field and select the rating field to output with the view.

    {{ post.rating }}

    #33435
    ChrisChris
    Participant

    Well, I downladed and installed the plugin from github - but the field does not show up in the view editor? What am I missing 😉

    #33436
    ChrisChris
    Participant

    OR actually, there is but it creates this block, not {{ post.rating }} like you write:
    {% set field = attribute( post, 'bewertung_-_rating' ) %}

    #33458
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The View will generate the field ID which you register under the meta box on step 4
    https://metabox.io/add-star-ratings-to-wordpress-on-backend/#step-4-create-custom-fields-to-add-star-ratings-with-mb-star-rating-plugin

    The plugin from Github helps you to create the custom field type. You also have to create a custom field based on that field type.

    But it will display the value of the rating field which should be 1, 2, 3 ... instead of stars. So you need to use the proxy to run the helper function rwmb_the_value() like the tutorial

    {{ mb.rwmb_the_value( 'rating' ) }}

    https://docs.metabox.io/rwmb-the-value/
    https://docs.metabox.io/extensions/mb-views/#running-php-functions

    I also see the file dashicons.ttf is missing in the plugin folder, you can copy it from the WP folder /wp-includes/fonts/dashicons.ttf to /wp-content/plugins/mb-rating-field-main/fonts/dashicons.ttf

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