Wrong date (today) instead of post date

Support MB Views Wrong date (today) instead of post dateResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #33612
    ChrisChris
    Participant

    I want to display the CPT date on a view but it shows the current date instead for '<div>{{ post.date | date( 'd.m.Y' ) }}</div>'

    I am using the following code for the view

    '
    {% set args = { post_type: "kundenbewertung", posts_per_page: 999 } %}
    {% set posts = mb.get_posts( args ) %}
    <div class="c-rating--parent">
    {% for post in posts %}
    <div class="c-rating--div">
    <div class="c-rating--firstrow">
    <div>
    {% set field = attribute( post, 'bewertung_-rating' ) %}
    {{ mb.wp_star_rating({ rating: field, type: 'rating' }) }}
    {{ field }}
    von {{ mb.get_the_title(post.ID) }}
    </div>
    <div>{{ post.date | date( 'd.m.Y' ) }}</div>
    </div>
    <div class="c-rating--secondrow">
    <p class="c-rating--text">
    {% set field = attribute( post, 'bewertung
    -text' ) %}
    {{ field }}
    </p>
    <p class="c-rating--text">
    {% set field = attribute( post, 'bewertung
    -_details' ) %}
    {{ field }}
    </p>
    </div>
    </div>
    {% endfor %}
    </div>
    '

    #33676
    Long NguyenLong Nguyen
    Moderator

    Hi Chris,

    If you want to display the post date in the custom query, please use the field post_date. For example:

    {% set args = { post_type: "kundenbewertung", posts_per_page: 999 } %}
    {% set posts = mb.get_posts( args ) %}
    {% for post in posts %}
        <div>
            Date: {{ post.post_date | date( 'd.m.Y' ) }} <br>
            Title: {{ post.post_title }}
        </div>
    {% endfor %}

    Refer to this documentation https://docs.metabox.io/extensions/mb-views/#custom-query

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