Skip Navigation

[Resolved] Can't Display Child Posts of the parent post displayed in Taxonomy Archive Loop

This support ticket is created 7 years, 6 months ago. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by Minesh 7 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#443655

I have created two Post Types: "Solutions" and "Case Studies". "Solutions" have a taxonomy called "Solution Type", which is used to categorize each of the "Solutions" post types.

I created a "Solutions" Taxonomy Archive page, which lists all the "Solutions" Custom Posts for that taxonomy. Now, on this page, I want to show a list of all "Case Studies" custom post types that are either: 1) Children of one of the "Solutions" custom post types on the page; or by the "Solutions Type" taxonomy.

Originally, I had the taxonomy "Solution Type" turned on for both "Solutions" and "Case Studies" post types, but when i tried creating my taxonomy archive loop page, I couldn't filter results by Custom Post Type. The message in Views said it would display posts from both post types.

So, I thought that I could use parent-child relationships between the "Case Studies" and the "Solutions" post to display the related "Case Studies" that matched one of the many "Solutions" that were being listed on this taxonomy archive loop page. But, no posts are displayed when I turn on the post relationship query filter.

I'm hoping this is simple, what am I missing?

#443838

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I need to understand your structure first and how you establish post-relationship.

1)
Could you please share problem URL of your archive page?

2)
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#444668

Minesh
Supporter

Languages: English (English )

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

As I understand - You want to display all "Case Studies" posts whose parent assigned to taxonomy -term "strategy"?

Originally, I had the taxonomy "Solution Type" turned on for both "Solutions" and "Case Studies" post types, but when i tried creating my taxonomy archive loop page, I couldn't filter results by Custom Post Type. The message in Views said it would display posts from both post types.
=> When you turn on taxonomy "Solution Type" for both "Solutions" and "Case Studies" post types, what if you create a page and create two different view's one for each post type to display results as you want?

#447260

Yes. I want to be able to classify the case studies using the same taxonomy categories as the Strategy. That way, when a strategy archive page is being displayed, any case study post that has the same taxonomy as the strategy listed, it will be displayed.

#447294

Minesh
Supporter

Languages: English (English )

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

I've added the following code to your current theme's functions.php file:

add_filter( 'wpv_filter_query', 'filter_by_parent_taxonomy', 10, 3 );
function filter_by_parent_taxonomy( $query_args, $settings, $view_id ) {
    if($view_id == 302){
        $args = array('post_type' => 'solutions',
		      'fields' => 'ids',
        		'tax_query' => array(
            array(
                'taxonomy' => 'solution-type',
                'field' => 'slug',
                'terms' => 'strategy',
            ),
        ),
     );

     $parent_ids= get_posts($args);
       $parent_ids[] = 0;
        if(!isset($query_args['meta_query'])){
            $query_args['meta_query'] = array();
        }
        $query_args['meta_query'][] = array(
            'key'     => '_wpcf_belongs_solutions_id',
            'value'   => $parent_ids,
            'compare' => 'IN',
        );


        
    }
    return $query_args;
}

Now, I can see the related child case studies posts attached to parent post type solutons taxonomy term strategy.
=> hidden link

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.