Skip Navigation

[Resolved] View is not filtering out child posts

This thread is resolved. Here is a description of the problem and solution.

Problem:
The issue here is that the user has a view but its not displaying the child posts of the current page that is being viewed.
Solution:
To display the child posts of the current please have a look at the link below.
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/

This support ticket is created 6 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)

Author
Posts
#613818
view.png
credform.png

I have two post types. Projects (Parent) and Proposals (Child).

I have created a view that gets the values of all users who have submitted a proposal by getting the post authors of all proposals that have been submitted. (see screenshot)

I have also created a CRED form with a generic select field that is using the view results as the value options. This CRED form is used to ‘Hire’ someone who has submitted a proposal. (see screenshot)

The form is placed on the project content template and when submitted it will edit the ‘Hired’ field for the project that is being viewed.

The only problem I am having is that I am unable to filter out the users that are displayed in the view that is being used to populate the select field.

Currently, it shows every user that has submitted a proposal on the site. I am trying to change this so it only shows users that have submitted a proposal for the project that a user is viewing.

Here’s a couple of things that I’ve tried:

1. I’ve added the following query filter to the view: Select posts that are children of… Post where this View is shown. I’ve placed this into the cred form which is then placed in the content template for projects. I’ve also placed the view directly into the content template and it still doesn’t work

2. For the proposal post type, I’ve created a field that gets the Post ID of the parent project. I used the wpv-conditional shortcode to see if the listing id field of the proposal in the loop and the post id of the current page matched and wrapped it around the view. This also did not work. If I place these two fields in the view, I can see that they match for some and not for others, but when I place them in the wpv conditional shortcode, they no longer work. Please see shortcode below.

[wpv-conditional if=“( $(wpcf-listing-id) eq '[wpv-post-id id=“$current_page"]' )”]
…..
[/wpv-conditional]

Any help or ideas you can provide will be greatly appreciated. Please let me know if you have any questions.

#613900

Shane
Supporter

Languages: English (English )

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

Hi Zach,

Thank you for contacting our support forum.

I would be happy to assist you with this.

To get an understanding you want to display items from your child post in a dropdown on the parent post page is that correct?

Also could you let me know which page is the CRED form on so that I can have a look at this. Finally to confirm the view you are having the issue with is the view with name "Hire Legal Professional List"

Please let me know.
Thanks,
Shane

#613901

Sure.

Yes, you are correct. I'd like to display the post author of all child posts (proposals) in the dropdown on the parent post (projects) page.

The CRED form is titled 'Hire Legal Pro' and the View is titled 'Hire Legal Professional List'. The CRED form was added in the 'View Project' content template.

Thanks!

#613922

Shane
Supporter

Languages: English (English )

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

Hi Zach,

Thanks for the clarity.

Please check the form now, I added it back to the page at the bottom because I wasn't seeing it.
hidden link

All the way at the bottom where you see Shane Test, you should now seeing the appropriate child being displayed. What I did was to add the parent filter to the view.

The next step I saw that you had this in your view

 {"value":"[wpv-post-author]","label":"[types usermeta='first-name' user_is_author='true' ][/types] [types usermeta='last-name' user_is_author='true' ][/types]"}

But the code would display the correct Post Author information for the value but the First Name and Last Name won't be displayed because its trying to get the information from the current logged in user.

In order to get the information for the author of the child post you will need to pass the ID into the usermeta shortcodes like this.

 {"value":"[wpv-post-author]","label":"[types usermeta='first-name' user_is_author='true' id='[wpv-post-author format='meta' meta='ID']'][/types] [types usermeta='last-name' user_is_author='true' id='[wpv-post-author format='meta' meta='ID']'][/types]"}

This should now work.

Please let me know if this helps.
Thanks,
Shane

#613964
beforeToolsetChanges.png
afterToolsetChanges.png

Hi Shane,

Thanks for the information. Unfortunately, it is still not working correctly. I removed your test. If you can enable private fields, I will share with you the front-end login with more instruction on how to to view the hire dropdown that I am seeing and what it should look like.

The first name and last name fields in the view actually were pulling in the correct information before making any changes. I’m including screenshots to show what I mean (I’ve hidden names with the name ‘test test’ for privacy’s sake).

The correct data is displaying in the dropdown. The problem is it is showing data for every proposal that has been submitted on the site, as opposed to the proposals that have been submitted for the project that we are viewing.

In WordPress, if you view the Proposals list, the title of the proposal matches the name of the parent project. If you then view a project (‘Test Project’ for example) and scroll down to post relationship, you will see that there are no proposals listed there, but when viewing the Proposals section, you will see that the first 9 proposals in the list are actually children of that project (‘Test Project’).

For this reason, I think there may be an issue with the parent-child relationship. This was working at one point, but just recently stopped working. Not sure if an update interfered with the work that was already there.

I hope this makes sense. Please let me know if you have any questions. Thanks!

#614286

Shane
Supporter

Languages: English (English )

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

Hi Zach,

I'm a little confused here as when I checked the view. There wasn't any filters attached to it, so it wasn't filtering at all. I'm not sure if you were using some custom hook to filter the view but what its suppose to do is to list the children of the current Project.

I checked this and added the filter for it to only list the children of the currently view Projects. As you said in your previous message it was listing every user and that was because the filter was missing.

For eg if you go to the Project - Test Project 1 you will see that at the bottom where i've added the view for the list beside the text THIS IS THE CURRENT VIEW

You will see that the view is ONLY listing out the children of the Test Project 1, without the filter it will be listing all the proposals and not just the one for the current Project.

Please let me know if this is correct now.

Thanks,
Shane

#614442

Hi Shane,

I see what you’re saying. It appears that maybe the view is working correctly, but the parent-child post relationship configuration is not working correctly. I think if we can get the relationship problem fixed, then the view will work perfectly with the filter.

Here’s an example:

I just added a new project titled Example Project 02/08.

I then submitted a proposal for that project on the project page.

When I view the proposal with the same title (Example Project 02/08) in WordPress, it shows that the parent project is Example Project 02/08, which is correct.

When I view this project (Example Project 02/08) in WordPress, it does not show any child proposals, which is incorrect. It should be showing the proposal mentioned above.

Any ideas why the project is not showing this proposal as a child?

You can also view the project and see that the dropdown is not appearing correctly (you can find this section in the middle of the page under the ‘Actions’ columns where it says ‘Hire a Legal Professional’ with blue HIRE button).

Please let me know what you think. I appreciate your help so far!

#614459

Shane
Supporter

Languages: English (English )

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

Hi Zach,

I found that the issue is in the CRED form used to create the proposal.

Could you adjust my user permissions so that I can have access to the form on the frontend ?

Thanks,
Shane

#614463

Okay, great. Could you tell me more about what needs to be fixed or changed?

As for the frontend form, if you could enable private fields, I will send a new front-end login. Because of the way it is configured, it will make more sense to send a front-end login than to adjust your permissions. Thanks!

#614658

Shane
Supporter

Languages: English (English )

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

Hi Zach,

The issue seems to be that the child post form isnt getting the parent information with this field.

<div class="hidden" style="display:none!important;">
		[cred_field field='_wpcf_belongs_legal-scout-project_id' value='' class='hidden' output='bootstrap']
	</div>

The only way I can say for sure or test this is to see the actual form on the frontend but I'm being blocked from seeing it by the message "Please select your membership level to submit a proposal. Click here to select your membership level."

But I highly suspect this as being the issue.

Thanks,
Shane

#614661

Okay, as I mentioned before, I'll be happy to share front-end login credentials with you if you enable private fields. I don't want to share them for everyone to see. What would be the correct way to get parent information with this form?

#614669

Shane
Supporter

Languages: English (English )

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

Hi Zach,

I thought you were referring to the credentials you initially provided.

However i'll enable the fields for you.

Thanks,
Shane

#614671
#614739

Shane
Supporter

Languages: English (English )

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

Hi Zach,

Thank you. It should now work as i've modified the parent field as follows.

		[cred_field field='_wpcf_belongs_legal-scout-project_id' value='[wpv-post-id]' class='hidden' output='bootstrap']

This should allow the parent information to be set in the field automatically.

Please let me know if this helps.
Thanks,
Shane

#615799

awesome, this fixed it. Thanks so much for all of your help!!