|
Broken output in tableview
Started by: Jacques Spijkers
in: Toolset Professional Support
|
|
2 |
21 |
7 years, 2 months ago
Minesh
|
|
I need to only display a loop view based on taxonomies for the parent post
Started by: garyF-3
in: Toolset Professional Support
Quick solution available
Problem: I have two Views of taxonomy terms, shown as tabs and tab panels, in a tab-based interface that allows users to select a term and show the associated term panel. This tab interface is displayed in a parent post type. In the tab panel of each term I include another View that shows all the child posts associated with that term. If no child posts are found, I do not want to show the tab or tab panel.
Solution: There's not a good way to apply conditional logic to a parent View that tests the output of a child View. Instead, you must apply a taxonomy query filter with the following custom code. This code loops over all the child posts associated with the current parent post, and builds an array of all the associated terms. If a term is not associated with any child, it will not be added. Then apply this as the "include" option in your taxonomy query as shown here:
add_filter( 'wpv_filter_taxonomy_query', 'prefix_only_assigned_tax_query', 10, 3 );
function prefix_only_assigned_tax_query( $tax_query_settings, $view_settings, $view_id ) {
global $post;
$views = [243391, 243393];
if( in_array( $view_id, $views) ) {
// query all credit posts and build an array of used cred-type terms
$ids = array();
$args = array(
'post_type' => 'credit',
'meta_query' => array(
array(
'key' => '_wpcf_belongs_website_id',
'value' => $post->ID
)
)
);
$ps = get_posts( $args );
foreach($ps as $post) {
// loop over each post and push its terms into the array
$terms = wp_get_post_terms( $post->ID, 'cred-type');
foreach($terms as $term) {
if( !isset( $ids[$term->term_id] ) ) {
$ids = array_merge($ids, array($term->term_id));
}
}
}
$ids = count($ids) ? $ids : array(9999999);
$tax_query_settings["include"] = $ids;
}
return $tax_query_settings;
}
Relevant Documentation: https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_taxonomy_query
https://codex.wordpress.org/Class_Reference/WP_Query
|
|
2 |
22 |
7 years, 2 months ago
garyF-3
|
|
include parent CPT in child CPT permalink
Started by: Joe H.
in: Types Community Support
|
|
2 |
3 |
7 years, 2 months ago
Joe H.
|
|
Linking to Types Field in Table
Started by: J S
in: Toolset Professional Support
|
|
2 |
5 |
7 years, 3 months ago
J S
|
|
Content disapearing after pagination
Started by: sebastienV
in: Toolset Professional Support
Quick solution available
Problem: I have a nested View setup where pagination occurs on the outermost View. When I navigate back and forth through the paginated results and return to the first page, some results are no longer found on my inner Views.
Solution: First Month View - uncheck "Don't include current page in query result"
Last Month View - uncheck "Don't include current page in query result"
Loop item in Home Agenda Events - add cached="off" to both First and Last Month View shortcodes.
|
|
2 |
3 |
7 years, 3 months ago
sebastienV
|
|
Query Parent data into View on Child?
Started by: Eric Anderson
in: Toolset Professional Support
Quick solution available
Problem:
How do I query data from Parent posts into Views being generated by Child posts?
I’m still trying to figure out how to display Product URL data conditional on the Product parent of the current Excerpt child.
The View display logic is like this:
1) get the Product parent of the current Excerpt child.
2) get the Product URL children of that parent Product.
3) get the Retailer parents of those Product URL children.
4) combine data from these sources and display in the View.
Where and how in Toolset do I build this conditional logic?
Solution:
I would suggest to change the relation between your CPT as follows:
In your case, we need to get data in this way. Excerpt >> to Product >> then product to Product URL and Retailer as follows:
Excerpt >> Product >> Product URL + Retailer
So that we need to update relation like this.
ProductURL..............Retailer [ 2 parents ]
|..........|..............|
|.........Product [ 1 intermediate child of both Product URL & Retailer ]
…………|
…….Excerpt [ 1 child of Product ]
- Then on Excerpt View1 we can get product data.
- And on Product View2 we can get Product URL and Retailer Data.
Alternatively, I suggest to make this setup bit less complex, so its easier for you to get and display Product URL, one way to do that is by adding ProductURL as custom field inside products or any other CPT, this way you will have one less CPT relation and it will most likely make it easier to display.
Relevant Documentation:
Please check this doc to get Grandparents data (Excerpt >> Product URL) into View:
https://toolset.com/documentation/user-guides/displaying-fields-grandparents/
|
|
2 |
14 |
7 years, 3 months ago
Eric Anderson
|
|
Need to display post title with link for a CPT linked via ACF relationship
Started by: Matthew Helmick
in: Toolset Professional Support
|
|
3 |
6 |
7 years, 3 months ago
Matthew Helmick
|
|
Shortcode not displaying parent post ID
Started by: HashimW3633
in: Toolset Professional Support
Quick solution available
Problem:
Shortcode not displaying parent post ID, [wpv-post-id id="$product"] is not working.
Solution:
For some reason that shortcode was not working directly in Beaver Builder module. I have added that by inserting shortcode (for parent post ID) into a new Content Template >> and then inserted that Content Template into the page.
Example shortcode:
[wpv-post-body view_template="ct-for-course-parent"]
|
|
2 |
7 |
7 years, 3 months ago
HashimW3633
|
|
Display Products Based on CPT Relationships – List not narrowed by criteria
Started by: Sarah Pickert
in: Toolset Professional Support
|
|
2 |
12 |
7 years, 3 months ago
Sarah Pickert
|
|
I need to only display parent posts that actually have children
Started by: Martin Duys
in: Types Community Support
Quick solution available
Problem:
Trying to create a page that Lists only the parent posts that actually have Children, not all the parent posts.
Solution:
1. Add this code in your theme’s or child theme’s functions.php file:
function child_exists_func( $atts ){
extract( shortcode_atts( array(
'child_post_type_slug' => '',
), $atts ) );
$child_posts = types_child_posts($child_post_type_slug);
if ($child_posts) {
return true;
}
}
add_shortcode( 'child-exists', 'child_exists_func' );
2. Register the ‘child-exists’ shortcode first in Toolset >> Settings >> Front-end Content >> Third-party shortcode arguments.
3. Then add this shortcode in your View >> Loop Output Editor:
[wpv-conditional if="( '[child-exists child_post_type_slug=belong]' eq '1' )"]
[wpv-post-link]
[/wpv-conditional]
==> Where as “belong” is your child post type slug that you should replace.
|
|
3 |
17 |
7 years, 3 months ago
Noman
|
|
Continued: "Messed up a structure" further questions CPT relationships
Started by: Lykke Scavenius
in: Toolset Professional Support
|
|
2 |
2 |
7 years, 3 months ago
Luo Yang
|
|
Conditional display of parent post
Started by: romanB-3
in: Toolset Professional Support
Quick solution available
|
|
2 |
3 |
7 years, 3 months ago
romanB-3
|
|
Show related content on single post view page
Started by: Cam Macduff
in: Toolset Professional Support
|
|
2 |
2 |
7 years, 3 months ago
Luo Yang
|
|
All options not showing in parent filter on archive
Started by: matthewL-6
in: Toolset Professional Support
|
|
2 |
3 |
7 years, 4 months ago
matthewL-6
|
|
view in View for parent child relationship.
Started by: stuart
in: Toolset Professional Support
Quick solution available
|
|
2 |
6 |
7 years, 4 months ago
stuart
|