'View' not working with custom post type

Support MB User Meta 'View' not working with custom post typeResolved

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #31424
    Marin KnezevicMarin Knezevic
    Participant

    Hello,

    I am trying to display data in a table from Frontend submition form on User profile. Website is about real estate, and I want to display all properties user added on their dashboard and allow the user to edit the prperty aw well as delete it. But when I try to display data with correct CPT slug I get blank page with nothing showing and no errors displaying.

    /-- VIEW --/
    {% set args = {post_type: 'nekretnine', posts_per_page: -1, orderby: 'date', order: 'ASC' } %}
    {% set posts = mb.get_posts( args ) %}
    <table>
    <thead>
    <tr>
    <td>Naziv nekretnine</td>
    <td>Adresa</td>
    <td>Grad</td>
    <td>Županija</td>
    <td>Poštanski broj</td>
    <td>Status nekretnine</td>
    <td>Veličina</td>
    <td>Broj soba</td>
    <td>Broj kupaonica</td>
    <td>Cijena</td>
    <td>Ostale informacije</td>
    <td>Vrsta nekretnine </td>
    </tr>
    </thead>
    <tbody>
    {% for p in posts %}
    <tr>
    <td>{{ p.post_title }}</td>
    <td>{{ mb.rwmb_meta( 'adresa', '', p.ID ) }}</td>
    <td>{{ mb.rwmb_meta( 'grad', '', p.ID ) }}</td>
    <td>{{ mb.rwmb_meta( 'zupanija', '', p.ID ) }}</td>
    <td>{{ mb.rwmb_meta( 'postanski_broj', '', p.ID ) }}</td>
    <td>{{ mb.rwmb_meta( 'status_nekretnine', '', p.ID ) }}</td>
    <td>{{ mb.rwmb_meta( 'velicina', '', p.ID ) }}</td>
    <td>{{ mb.rwmb_meta( 'broj_soba', '', p.ID ) }}</td>
    <td>{{ mb.rwmb_meta( 'broj_kupaonica', '', p.ID ) }}</td>
    <td>{{ mb.rwmb_meta( 'cijena', '', p.ID ) }}</td>
    <td>{{ mb.rwmb_meta( 'ostale_informacije', '', p.ID ) }}</td>
    <td>{{ mb.rwmb_meta( 'vrsta_nekretnine', '', p.ID ) }}</td>
    <td>{{ mb.rwmb_meta( '_thumbnail_id', '', p.ID ) }}</td>
    </tr>
    {% endfor %}
    </tbody>
    </table>

    #31437
    Long NguyenLong Nguyen
    Moderator

    Hi,

    If you want to show the list of posts of the user submitted from the frontend submission page, you can create the frontend dashboard to show them. Please get more details on the documentation https://docs.metabox.io/extensions/mb-frontend-submission/#user-posts-dashboard

    If you want to use the View shortcode to render the code anywhere, please set the Type to Shortcode, screenshot https://share.getcloudapp.com/mXuPm6L0
    Then put the shortcode to the page that you want to show CPT.

    #31494
    Marin KnezevicMarin Knezevic
    Participant

    Hi Long,

    Thank you very much for your help, I managed to render all the data I needed from the view. My next question would be, how can a user, that is logged in, edit or delete the data.

    Thank you! 🙂

    #31500
    Long NguyenLong Nguyen
    Moderator

    Hi Marin,

    What's the data that you want to allow the user to edit/delete? If it is the post data that the user submitted, you can use the frontend dashboard shortcode
    https://docs.metabox.io/extensions/mb-frontend-submission/#user-posts-dashboard

    #31519
    Marin KnezevicMarin Knezevic
    Participant

    Hi Long,

    Yes it is the post data that the user submited, but for some reason it not working. It says that Something is wrong with the shortcode on the page id, which I changed to page I want to display submitions. I am curious, does it have anything to do with the Oxygen builder? Could that be the reason why it is not working?

    Thank you Long

    #31523
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Please update the new version of MB Frontend Submission 3.1.5 or MB AIO 1.15.2 to use the frontend dashboard shortcode in the Oxygen builder.

    #31531
    Marin KnezevicMarin Knezevic
    Participant

    Hi Long,

    I updated the plugin, but still getting the same output. What else can I do to fix this?

    #31540
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Can you please clear all caches and re-check this issue? If not, please share some screenshots on your end about two pages with shortcodes.

    #31546
    Marin KnezevicMarin Knezevic
    Participant

    Hi,

    I cleared all caches and nothing changed.

    User Dashboard Page:

    Shortcode: [mbv name="tablica-nekretnina"]
    View: {% set args = {author:user.ID , post_type: 'nekretnina', posts_per_page: -1 } %}
    {% set posts = mb.get_posts( args ) %}
    {% for post in posts %}

    <table>
    <tr>
    <th>Naziv nekretnine: {{ post.post_title }}</th>
    <th>Adresa: {{post.adresa}} </th>
    <th>Grad: {{post.grad}} </th>
    <th>Županija: {{post.zupanija}}</th>
    <th>Poštanski broj: {{post.postanski_broj}} </th>
    <th>Status nekretnine: {{post.status_nekretnine}}</th>
    <th>Veličina: {{post.velicina}} </th>
    <th>Broj soba: {{post.broj_soba}} </th>
    <th>Broj kupaonica: {{post.broj_kupaonica}} </th>
    <th>Cijena: {{post.cijena}} </th>
    <th>Ostale informacije: {{post.ostale_informacije}} </th>
    <th>Slika: {{ mb.get_the_post_thumbnail( post.ID, '_thumbnail_id' ) }}</th>
    <tr/>
    </table>
    {% endfor %}

    Frontend Edit Page
    Shortcode: [mb_frontend_dashboard edit_page="438"]

    You can find screeenshots here: https://nx7439.your-storageshare.de/s/mSAepD75n5fHdHH

    #31553
    Long NguyenLong Nguyen
    Moderator

    Hi Marin,

    You need to create the page and add the frontend submission shortcode and add its ID to the frontend dashboard shortcode to make the frontend dashboard works.

    [mb_frontend_form post_fields="title,content"]
    

    The user dashboard page shows the list of posts and information of the user does not relate to the frontend dashboard, just a static page.

    Please read the documentation step by step https://docs.metabox.io/extensions/mb-frontend-submission/

    #31698
    Marin KnezevicMarin Knezevic
    Participant

    Hi Long,

    Thank you so much for your time, we made it work 🙂

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