Navigation überspringen

[Gelöst] Repeatable Fields Inside of view_template on Page

This support ticket is created vor 3 years, 2 months. 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Zeitzone des Unterstützers: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 3 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von aaronW-4 vor 3 years, 2 months.

Assistiert von: Minesh.

Author
Artikel
#2574691

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.

You can see my issue here:
versteckter Link

#2574827

Minesh
Unterstützer

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

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.

#2575271

Minesh
Unterstützer

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

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:
=> versteckter 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:
=> versteckter Link

#2575277

It works perfectly! Thank you!