How to display custom fields on cards on LearnPress archive page?

Support MB Views How to display custom fields on cards on LearnPress archive page?Resolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #33791
    UnakritiUnakriti
    Participant

    Hi Support,

    I have created a custom field (type: datepicker, label: upcoming batch) for LearnPress plugin. The custom field shows up and works okay on the backend when creating a new course (LearnPress CPT). LMS admin can set a date for an upcoming batch.

    However, I am unable to display this field on the All Courses archive page inside the cards section (please refer to the screenshot here - https://imgur.com/a/MbiZyZx). I am using MB Views to accomplish this - I have tried to render the view using actions too - but nothing works. Could you please help with a solution?

    Kind regards,

    #33795
    UnakritiUnakriti
    Participant

    PS: For this display location, LearnPress team had suggested to use hooks from a file documented here - https://github.com/LearnPress/learnpress/blob/develop/templates/content-course.php

    PS: I tried an action 'learn-press/courses-loop-item-title' and others listed therein. But it does not work for me. Appreciate your help please.

    Kind regards,

    #33811
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can try to use this code to output the datepicker value in the loop

    add_action( 'learn-press/courses-loop-item-title', function() {
        $post_id = get_the_ID(); //get post ID in the loop
        $date_picker = rwmb_meta( 'date_picker_id', '', $post_id ); //get field value based on the post ID
        echo $date_picker;
    } );

    Refer to this documentation https://docs.metabox.io/rwmb-meta/

    #33813
    UnakritiUnakriti
    Participant

    Thank you so much Long Nguyen. It works but replaces the item title on the card.

    I want to display the date field underneath the title.

    Any advise please?

    Kind regards,

    #33823
    UnakritiUnakriti
    Participant

    Hi Long Nguyen,

    Your code is good and works . I just had to change the hook / location. All good. Appreciate your support.

    PS: You may please close this ticket

    Kind regards,

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