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 - 856 through 870 (of 1,097 total)
Problem:
How to dispaly parent/chid post related content using views.
Solution:
To display related content of parent/child posts you need two views. One view to display parent CPT data and one view to display the child CPT data.
You can find proposed solution with the reply here
Problem:
Views filter controls does not update perfectly when we want them to work in a related fashion, like:
- First level parent filter - Categories (radios)
- Second level child filter - Sub-Categories (checkboxes)
Whereas we need to keep parent filters always visible and child filters only appear when we select parent one and should automatically reset as we deselect child filters.
OR setup search Filters by hierarchical taxonomy, or changing taxonomy filters based on selection.
Solution:
Currently it is required to press “Reset” button every time, when 2nd level filtration is done on the results. Relation based advanced filtering is not available for parent-child taxonomies or posts (for the description in the above example) .We have submitted this as a feature request to our development team which is under consideration.
Problem:
I have a child post with a CRED add form (id of the parent post in the URL string "parent_parent-cpt_id"), but I would like to show the form to the user only if a custom field of the parent's post has a certain value "status=open", Is that possible?
Solution:
You can get the URL parameter value with Views shortcode [wpv-search-term]
For example:
1) Create a content template "parent-post-information"
in content, use Views shortcode [wpv-conditional] to check if current parent post has setup "status=open", then display the CRED form for creating child post
2) Display the content template like this:
[wpv-post-body view_template="parent-post-information" id=[wpv-search-term param='parent_parent-cpt_id']]
Please replace the "parent-cpt" with the parent post type slug.
Problem:
How can I display Child Posts, in a View that queries the parent posts and has a Custom Search?
Solution:
1. Create the View with Parent Posts and the Custom Search
2. Create a View that queries the Child Posts and choose a Query Filter like "Posts set by the parent view"
3. Insert this last View to the first View's Loop
4. Insert the first view to a page.
Problem: I would like to create a View that shows Parent posts that have children. If the parent post has no children, I would not like it to show up.
Solution:
Use the wpv_filter_query filter to modify the 'post__in' parameter in the WP Query. In this case, you must intersect with the existing array generated by the View settings (only children of the current post).
add_filter('wpv_filter_query', 'parent_has_childs_func', 101, 3);
function parent_has_childs_func($query, $view_settings, $view_id) {
if ( $view_id == 1303 ) {
global $wpdb;
$ids = array();
$metas = $wpdb->get_results( "SELECT meta_value FROM wp_postmeta WHERE meta_key = '_wpcf_belongs_county_id'");
foreach($metas as $id) {
if(isset($id->meta_value)) {
$ids[] = $id->meta_value;
}
}
$query['post__in'] = array_intersect($query['post__in'], $ids );
}
return $query;
}