'View' not working with custom post type
Support › MB User Meta › 'View' not working with custom post typeResolved
- This topic has 10 replies, 2 voices, and was last updated 3 years, 6 months ago by
Marin Knezevic.
-
AuthorPosts
-
October 21, 2021 at 3:06 PM #31424
Marin Knezevic
ParticipantHello,
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>October 21, 2021 at 10:45 PM #31437Long Nguyen
ModeratorHi,
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.October 25, 2021 at 7:34 PM #31494Marin Knezevic
ParticipantHi 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! 🙂
October 25, 2021 at 10:00 PM #31500Long Nguyen
ModeratorHi 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-dashboardOctober 26, 2021 at 3:34 PM #31519Marin Knezevic
ParticipantHi 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
October 26, 2021 at 9:44 PM #31523Long Nguyen
ModeratorHi,
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.
October 27, 2021 at 2:23 AM #31531Marin Knezevic
ParticipantHi Long,
I updated the plugin, but still getting the same output. What else can I do to fix this?
October 27, 2021 at 3:18 PM #31540Long Nguyen
ModeratorHi,
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.
October 27, 2021 at 4:58 PM #31546Marin Knezevic
ParticipantHi,
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
October 27, 2021 at 11:00 PM #31553Long Nguyen
ModeratorHi 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/
November 2, 2021 at 4:23 PM #31698Marin Knezevic
ParticipantHi Long,
Thank you so much for your time, we made it work 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.