Skip Navigation

[Closed] Custom Post Type Childs

This support ticket is created 9 years, 11 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 7 replies, has 2 voices.

Last updated by Luo Yang 9 years, 11 months ago.

Assigned support staff: Luo Yang.

Author
Posts
#76526

Hi, i got an event website with 2 custom post types: "places" & "events"

In some pages (not places pages) i need to show only events relatives to a certain choosen place.

With views i can use search filters via shortcodes to retrive certain taxonomy value etc.. but with parents it is impossibile i see.

It is a my misunderstanding or there a way?

#76867

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hi Alessandro,

Could you describe the quesion with more details?

Is there any relationship between post types: "places" and "events"?

If "place" is parent post type of "events", you can get all events relatives to a certain choosen place:

Querying and Displaying Child Posts:
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/

Please let me know if you need assistance to do it

Regards
Luo

#76904

Hi Luo,
as you can see in the link you send me:
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/

When querying child posts in the view you have 3 options:

"post where this field is inserted"
"post set by parent page"
"specific"

There is any option to set the parent post via shortcode

#76907

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

To set the parent post, please try this with Types:
https://toolset.com/documentation/user-guides/creating-post-type-relationships/

Please let me know if you need assistance to do it

#76992

I have just setted the post relationship
I need to show chid(events) of a certain parent(place) via shortcode

Something like this

[wpv-view name="Events by places" parentplace=placeName]

#77341

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

You can pass parameters to your view "Events by places":
Passing Arguments to Views, Controlling the filter with shortcode attributes

https://toolset.com/documentation/user-guides/passing-arguments-to-views/

And there are lots document about using Views:
https://toolset.com/documentation/user-guides/#Views

Please let me know if you need assistance to do it

#77428

Sorry, i'm going to think you are using presetted answers.

I already told you it is not possible to pass argument where argument is the parent post (my 2° question) because when you set what to filter it by parent it show only this 3 options:

"post where this field is inserted"
"post set by parent page"
"specific"

Also if you read the page you send me:
https://toolset.com/documentation/user-guides/passing-arguments-to-views/

IT SAYS:

Arguments let you control query filters by:

Custom fields
Taxonomy
Author

It is not mentioned parent posts

Please if you don't know the answer pass me to another person of the staff

#77453

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Sorry for the misunderstand, you are right, there is no way to apply such a shortcode parameters directly. but you can try use views filter "wpv_view_settings" to do it, like this:

1) Create a view "Events by places"
Filter with:
events, ordered by post date, descending
Select related posts that are a child of place 1. (place 1 is any one post of your post type "place")

2) add codes in your theme/functions.php:

add_filter('wpv_view_settings', 'modify_rendered_views');
function modify_rendered_views($view_settings) {
    // do something to $view_settings
	global $WP_Views;
    if($WP_Views->current_view == 991)
	{
		$view_shortcode_attributes = $WP_Views->view_shortcode_attributes;
		$parentplace = $view_shortcode_attributes[0]['parentplace'];
		$view_settings['post_relationship_id'] = $parentplace;
	}
    return $view_settings;
}

replace 991 with view "Events by places" post ID

3) modify the shortcode in your content:

[wpv-view name="Events by places" parentplace="996"]

996 is your certain parent(place) post ID

Please let me know you need assit to do it.

More help: https://toolset.com/documentation/user-guides/views-filters/

The topic ‘[Closed] Custom Post Type Childs’ is closed to new replies.