Skip Navigation

[Resolved] Unable to list Child Posts Using Toolset API and Custom Code Section

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 26 replies, has 3 voices.

Last updated by himanshuS 3 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#1897823

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Himanshu,

So essentially you want to list out the endorsement posts by the current user.

You can still build out the custom query in views and add your the elementor template that you've created. If you go to Toolset -> Settings -> Editing Experience and select the 3rd option.

From there you can refresh the page and then you should see the classic views option in Toolset -> Views. You can build out a classic view here where you can add a Post Author Query filter to filter the post type based on the current user.

Once you've done this and setup the view output in the Loop Editor . Finally all you need to do is to go to your elementor template and add your view shortcode to the template.

Add it like this [wpv-view name='my-view' ] where my-view is the slug of your view.

I dont believe custom code is needed for this as we try to avoid using custom coding as best as possible as this would be something that is out of our support scope as Minesh had mentioned.

Thanks,
Shane

#1897847

Shane,

I think I was not very clear. I don't want to show endorsement by current user. That would mean current user has 'given' endorsement to someone else.

I want to know endorsements 'received' by the current user i.e. endorsements that are children to the endorsement request submitted by the current user.

So I want: list of child posts whose parent post was authored by the current user.

I hope that helps.

#1897875

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Himanshu,

I believe I understand a little clearer now, so this would require a nested view setup.

View 1 will be the parent view that will be filtered by the current user and view 2 will be filtered by the parent view. This in turn will give you the Child posts .

How is the endorsements added to the parent post? Is it through a custom field ? Can you send me a screenshot so that I can see exactly what the endorsement field hold. Perhaps even a short video clip of the Data that we should be filtering for.

This is because if we know the fields that holds the data in the parent it will be just a case of Filtering for the Parent and then just adding a child view to that parent view which will list the children based on that parent view.

Thanks,
Shane

#1897921
give-endorsement.png

Good questions.

The data is being passed using URL params like this :
hidden link

You can see the vide here: hidden link

So the endorsement request id is passed into the relationship field using url param endorsement-request-id. This one makes the relationship happen when the form is published.

I have also attached the screenshot of give endorsement form. I have hidden the relationship field and other fields on the front end but they are passed to the form.

#1898731

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Himanshu,

Take a look at my short snippet.
hidden link

As you can see i'm currently filtering the parent view with the static email "himanshu.tevotia@gmail.com" however to make it dynamic you can just replace it with this.
[wpv-current-user info="email"]

This should pass the current user's email into the parent view.

What I have is that under each endorsement request is the endorsement that was given for that request.

Please let me know if this looks like what you're trying to achieve.

Thanks,
Shane

#1898903

Hi Shane,

I am not sure why you selected email as filter for parent endorsement requests. Could we not just do it by post author is current user filter?

Secondly, this is a good approach to use in many situations but I am looking for a way to show endorsements received standalone without the endorsement request information. Because, the user does not care about a request once they have received an endorsement. They just want to see their endorsements.

In other words, I only want to see the child posts (published by unregistered user) that are related to the parent post (published by the current user) without showing the parent posts.

Does that make it clear?

#1898907

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Himanshu,

Secondly, this is a good approach to use in many situations but I am looking for a way to show endorsements received standalone without the endorsement request information. Because, the user does not care about a request once they have received an endorsement. They just want to see their endorsements.

Yes you can filter by the post author to be the currently logged in user. Secondly you can remove the output of the Parent view and just allow the Parent view to list out only the Information from the child view.

What I did was to do a simple test to ensure that the correct data is being returned. However changing the filter to the Post Author instead of the email and removing the post title output from the parent view should resolve the issue.

Thanks,
Shane

#1898911

Thanks Shane. Let me try to solve this based on your instructions. Give me some time, I will get back to you soon.

#1898971

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Himanshu,

Great, if there are any issues you can just let me know .

Thanks,
Shane

#1900585

Shane,

I was able to generate the right number of posts using the nested view but I still have three issues:
1) I want the posts to be visible in column of 3 with a max of 6 posts. I put that restrictions on the view ( tried on both views and just one view) but that doesn't seem to work.
2) I want the posts to be of same height
3) I want to remove no post found when the loop does not have a post. I think I can do this by remove no post found section but I wanted to confirm with you.

Important note: My template is coming from elementor via a shortcode and that shortcode has been added to a Toolset template.

Video link here: hidden link

View 1 to list all endorsements related to the loop post - hidden link

View 2 (contains view 1) to show only endorsement requests that are published by the current user - hidden link

For view 2, I am not showing any information related to the endorsement request as I just need to show the endorsements that have been received.

#1901325

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Himanshu,

1) I want the posts to be visible in column of 3 with a max of 6 posts. I put that restrictions on the view ( tried on both views and just one view) but that doesn't seem to work.

Ok so if you want the columns to work correctly you will need to set it on the Parent View. I'm assuming you want something like this below.

Col 1 Col 2
-A -D
-B -E
-C -F

Where ABCDEF are the received endorsements. You will need to go back to the parent view and setup the columns here using the Loop Output. Secondly i'm assuming that the ABCDEF you want to restrict each column to only displaying 6 items. In such a case you've already set this in your child view.

2) I want the posts to be of same height

This will take some CSS manipulation to achieve.

3) I want to remove no post found when the loop does not have a post. I think I can do this by remove no post found section but I wanted to confirm with you.

Thats correct, removing the No Post Found from the view will indeed remove this text from the frontend.

Thanks,
Shane

#1901565

My issue is resolved now. Thank you!