Views is a WordPress plugin that lets you display post relationships.
In our user guides, you can find more information on how to display child posts, related posts, brother pages, fields of parents and fields of grandparents.
When you ask for help or report issues, make sure to tell us the type of the relationship you are trying to build and the structure of your data.
Viewing 15 topics - 631 through 645 (of 659 total)
Problem: When I filter a View with AJAX, the first result isn't styled correctly.
Solution:
There is an issue with iterative CSS class names Divi must resolve. Until then, it's best to disable AJAX updates and apply styles with CSS instead of applying module styles in the Content Template with Divi Builder.
The issue here is that the user wanted to filter to out their existing relationships so only parents without children will show in the list.
Solution:
Unfortunately I do not have a way to filter this out. Currently this is still a new feature to our Toolset Forms plugin and improvements are constantly being made.
I see on our system that a request for this has already been logged.
So this is something that will be added in a future release.
Problem: I have a post relationship between two post types. I want to show a View of child posts where the parent post is not private.
Solution: Use custom code to test each child post's parent. Private parent posts will not be returned for any guest Users. Also test the post status, so logged-in Users will not see child posts of their own private parent posts.
add_filter('wpv_filter_query', 'ts_parent_not_private_func', 10, 3);
function ts_parent_not_private_func($query, $view_settings, $view_id) {
$views = array( 16813, 16403 ); // only filter these views
if( in_array( $view_id, $views ) ) {
$child_ids = array(); // we will push IDs here if the parent is not found, or private
$children_args = array(
'post_type' => 'training-datum',
'posts_per_page' => '-1',
'post_status' => 'publish',
// you may want to add more filters here to improve the performance of this query
);
$children = new WP_Query($children_args);
foreach( $children->posts as $child ){
$parent = toolset_get_related_post( $child, 'training_training-datum', 'parent' );
// if there is no parent or the parent is private, push this ID into the exclusion array
if( !$parent || get_post_status($parent) == 'private' ){
array_push( $child_ids, $child->ID );
}
}
$query['post__not_in'] = isset( $query['post__not_in'] ) ? $query['post__not_in'] : array();
$query['post__not_in'] = array_merge($query['post__not_in'], $child_ids );
}
return $query;
}
I am trying to sort view results using a M2M intermediary post field but it shows "No results found".
Solution:
Views plugin is using wordpress class WP_Query to query the posts, so if you are ordering the result by custom field, then all posts should have the value in this custom field.
In your case, I suggest you setup a post view, query posts of the intermediary post type, order result by the intermediary post field, in the view's loop display the related(parent) post information:
Problem:
A View lists posts of one type which are in a relationship with another post type. How to list fields from the related posts?
Solution:
Use the Fields and Views button to insert the field and use the Post Selection tab to specify that the source for the field should be the related post rather than the default current post, and that will insert the shortcode with the required attributes (namely the item="$relationship-slug.parent|child" arribute).
Problem: I have a View of child posts. I would like to apply a query filter so that the View only shows children of parents that are NOT marked "private".
Solution:
This type of filter does not exist, but you can add some custom code using the wpv_filter_query and toolset_get_related_posts APIs to create the query in code.
add_filter('wpv_filter_query', 'ts_parent_not_private_func', 10, 3);
function ts_parent_not_private_func($query, $view_settings, $view_id) {
$views = array( 16813, 16403 ); // only filter these views
if( in_array( $view_id, $views ) ) {
$child_ids = array(); // we will push IDs here if the parent is not found, or private
$children_args = array(
'post_type' => 'training-datum',
'posts_per_page' => '-1',
'post_status' => 'publish',
// you may want to add more filters here to improve the performance of this query
);
$children = new WP_Query($children_args);
foreach( $children->posts as $child ){
$parent = toolset_get_related_post( $child, 'training_training-datum', 'parent' );
// if there is no parent or the parent is private, push this ID into the exclusion array
if( !$parent || get_post_status($parent) == 'private' ){
array_push( $child_ids, $child->ID );
}
}
$query['post__not_in'] = isset( $query['post__not_in'] ) ? $query['post__not_in'] : array();
$query['post__not_in'] = array_merge($query['post__not_in'], $child_ids );
}
return $query;
}