I am trying to show a specific custom post inside it's content template on a page by using the following shortcode:
[wpv-post-body view_template="copywriting-single" id="858"]
Inside of my content template I have some views to show repeatable field groups. These views are showing "No Items Found" when I use the shortcode on a page.
Hello. Thank you for contacting the Toolset support.
Can you please share admin access details and let me check whats going wrong with those views that is not displaying the correct repeatable group items.
I have set the next reply to private which means only you and I have access to it.
As you are using the block based view there is no way to catch the shortcode argument you passed to the content template as "id".
Also - the block views you created to display the repeating field group are tied to display the current post instead of the post ID you added to content template as "id" attribute.
So - there was a great possiblity that you may have to create new views but to save all those time I've added the following view's query filter to the custom code section offered by Toolset:
=> hidden link
function func_show_rfg_posts( $query_args ,$view_settings, $view_id ) {
$target_view_ids = array( 898, 895, 890, 913);
if ( in_array($view_id, $target_view_ids) ) {
$parent_id = 858;
if($view_id==898){
$post_relationship_slug = 'copywriting-section';
}else if($view_id==895){
$post_relationship_slug = 'primary-section';
}else if($view_id==890){
$post_relationship_slug = 'quote';
}else if($view_id==913){
$post_relationship_slug = 'tagline';
}
$result = toolset_get_related_posts(
$parent_id, // get posts related to the current post (product)
$post_relationship_slug, // relationship between the posts
'parent', // get posts where product is the child in given relationship
999, 0, // pagination
array(), // no extra args needed here
'post_id', // return post objects
'child' // return the related parent post(s) in this relationship
);
if(!empty($result)){
$query_args['post__in']=$result;
}else{
$query_args['post__in']=array(0);
}
}
return $query_args;
}
add_filter( 'wpv_filter_query', 'func_show_rfg_posts', 99, 3);
Can you please confirm it works as expected:
=> hidden link