- There is a CPT called Vehicles with children called Vehicle Records. John Doe creates a Vehicle Post called "VW Rabbit." Then David Rogers (another author/user) creates a Vehicle Record for the "VW Rabbit" called "Oil Change." What I want to do is show a list of Vehicles that David Rogers has created Child Posts for. So essentially display an author-specific view of vehicles driven by the author meta data of the child posts. So in David Rogers' author profile page we would see the VW Rabbit listed because he created a vehicle record (child post) for that vehicle.
===>
This is possible.
If you are on user profile page, you will get author ID using the function get_queried_object_id()
You need to create two views here - one for your parent post type (Vehicles ) and one view for child post type (Vehicle Records). Please check following steps.
1) Create view namely "parent-view-Vehicles"
2) Create another view namely "child-view-Vehicle-Records"
2-a)
- Add query filter to view - Post relationship filter:
Select posts that are children of the Post with ID set by the shortcode attribute wpvprchildof.
eg. [wpv-view name="view-name" wpvprchildof="123"]
- Add query filter - filter by author:
Post author filter
Select posts which author's id is set by the View shortcode attribute "author" eg. [wpv-view name="view-name" author="1"]
2-b) Navigate to "loop output editor" and add shortcode:
[wpv-post-title id="$vehicle"]
3) Add child view "child-view-Vehicle-Records" to your parent view "parent-view-Vehicles" loop output editor section.
[wpv-view name="child-view-Vehicle-Records" wpvprchildof="[wpv-post-id]" author="[wpv-current-user info='id']"]
Then - as you are using PHP template to dispaly the author info. You can use views API to dispaly the above views with your PHP author.php template file:
=> https://toolset.com/documentation/user-guides/views-api/
=> https://toolset.com/documentation/user-guides/filtering-views-query-by-author/
So - using views API you can add view to your PHP template file. For example:
$args = array(
'id'=>9999,
);
echo render_view( $args );
Where:
- Replace 9999 with your view ID. In your case - your parent view id.
We have complete guidance available with our Docs about creating user profiles:
=> https://toolset.com/documentation/customizing-sites-using-php/creating-custom-user-profiles/