Skip Navigation

[Resolved] Get terms from children posts

This thread is resolved. Here is a description of the problem and solution.

Problem:

I would need to display most popular terms for all children posts of a parent post type.

Solution:

It needs custom codes, for example:

https://toolset.com/forums/topic/get-terms-from-children-posts/#post-1690215

Relevant Documentation:

This support ticket is created 4 years, 5 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 27 replies, has 3 voices.

Last updated by romanB-3 4 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1696983

Thanks for the details, I can see problem A) AND B) in your website, and have done below modifications in your website, edit the post view "Liste des domaines de formation de cet établissement", in section:

Change the codes from:

[wpv-layout-start]
    [wpv-items-found]
	<hr>
    <h2>Domaines de formation<span class="seo-friendly"> de cet établissement</span></h2>
    <!-- wpv-loop-start -->
        <wpv-loop>
            [wpv-item index=other]
                [wpv-post-taxonomy type="domaine" format="link" separator=","], 
            [wpv-item index=last]
                [wpv-post-taxonomy type="domaine" format="link" separator=","]
        </wpv-loop>
    <!-- wpv-loop-end -->
    [/wpv-items-found]
    [wpv-no-items-found]
    [/wpv-no-items-found]
[wpv-layout-end]

To:

[wpv-layout-start]
    [wpv-items-found]
    <!-- wpv-loop-start -->
        <wpv-loop>[wpv-item index=other][wpv-post-taxonomy type="domaine" format="link" separator=","],[wpv-item index=last][wpv-post-taxonomy type="domaine" format="link" separator=","]</wpv-loop>
    <!-- wpv-loop-end -->
    [/wpv-items-found]
    [wpv-no-items-found]
    [/wpv-no-items-found]
[wpv-layout-end]

This will remove unrelated contents and blank spaces,

for the problem C, I have changed the PHP codes to:

...
        foreach ($view_output_unique as $key => $val) {
			if(ctype_space($key)){
				continue;
			}
            $output .= $key.' ('.$val.'), ';
        }
...

More help:
hidden link

Please test again, check if they are fixed, thanks

#1704969

Hello and thank you very much,
This in deed solved most of the problems.
Nevertheless, now I would need to be able to use a conditional display based on the view results.
If the view has no result, then don't display anything.
That doesn't work since as soon as I put something in the [wpv-no-items-found] [/wpv-no-items-found] tags, it displays with the "(1)" on front end.
How may I disable this "(1)" if there is no result ?
Thank you.

#1706071

You don't need put anything into shortcode [wpv-no-items-found] [/wpv-no-items-found], you can use wpv-conditional shortcode to check that custom shortcode outputs, for example:
1) Dashboard-> Toolset-> Settings-> Front-end Content
in section "Third-party shortcode arguments", add the custom shortcod name: show_related_domaines

2) Add below line into content template "Infos pour établissement":
hidden link
Line 37:

[wpv-conditional if="( '[show_related_domaines view="liste-des-domaines-de-formation-de-cet-etablissement"]' eq '')"] Display something else [/wpv-conditional]

Then test again

#1706193

Thank you.
I tried this and put my whole conditional code into wpv-conditional without success :

      [wpv-conditional if="( '[show_related_domaines view="liste-des-domaines-de-formation-de-cet-etablissement"]' ne '')"]
      <hr>
      <h2>Domaines de formation<span class="seo-friendly"> de l'établissement</span></h2>
      [show_related_domaines view="liste-des-domaines-de-formation-de-cet-etablissement"]
      [/wpv-conditional]
      [wpv-conditional if="( '[show_related_domaines view="liste-des-domaines-de-formation-de-cet-etablissement"]' eq '')"] Display something else [/wpv-conditional]

The "Display something else" displays alright when view returns no result, but the main code don't display anymore, even if the view returns something.

#1706383

The wpv-conditional shortcode does not support complicated codes, I have done below modifications in your webiste:
1) Edit the PHP codes, line 94, replace it from:
'view' => '',
To:
'view' => 'liste-des-domaines-de-formation-de-cet-etablissement',

2) Edit the content template "Infos pour établissement", line 34~39, use below codes to display different results:

[wpv-conditional if="( !empty('[show_related_domaines]') )"]
      <hr>
      <h2>Domaines de formation<span class="seo-friendly"> de l'établissement</span></h2>
      [show_related_domaines view="liste-des-domaines-de-formation-de-cet-etablissement"]
      [/wpv-conditional]
      [wpv-conditional if="( '[show_related_domaines view="liste-des-domaines-de-formation-de-cet-etablissement"]' eq '')"] Display something else [/wpv-conditional]

Please test again, check if it is fixed, thanks

#1706419

Thank you.
I tried this solution but it doesn't seem to solve the problem: the Etablissement with Formations still don't display anything, where the Etablissement with no Formation still display "Display something else".
Thank you.

#1707455

I can not edit your PHP codes in admin side any more, I get these errors even click the "Update button" here:
hidden link

Allowed memory size of 536870912 bytes exhausted (tried to allocate 5064008 bytes)

Then I have tried the FTP access you provided:
https://toolset.com/forums/topic/get-terms-from-children-posts/#post-1691265

It is not valid, I can see only an empty folder after login the your FTP access.

Please check it, make sure your FPT access is valid, it needs to modify the PHP codes

#1707513

Hi,
I've just tested the ftp credentials here https://toolset.com/forums/topic/get-terms-from-children-posts/#post-1691265 and I confirm those work ok.
Thank you.

#1707573
ftp2.JPG

I have tried the FTP access lots of time, it does not work, I can see an empty folder and error message: Failed to retrieve directory listing

see my screenshot ftp2.JPG

You can also provide a full copy of your website in below private message box, I can test and debug it in my localhost:
https://toolset.com/faq/provide-supporters-copy-site/

#1707681

Could you please try with a VPN enabled ?
Also please feel free to install an FTP plugin on the site to explore the files directly from WP.
Finally, if it still doesn't work, could you please enable confidential message in order to allow me to give you another access ?
Thank you.

#1708435

I have tried with VPN, same problem, please provide an valid FTP/SFTP access in below private message box

#1708563

The new FTP access does not work too, I have done below modifications in your website:
1) Add a custom snippet:
hidden link
It will create a new shortcode [show_related_domaines2], and output the term count as number

2) Edit the content template:
hidden link
line 35~40:

      [wpv-conditional if="( '[show_related_domaines2]' gt 0 )"]
      <hr>
      <h2>Domaines de formation<span class="seo-friendly"> de l'établissement</span></h2>
      [show_related_domaines view="liste-des-domaines-de-formation-de-cet-etablissement"]
      [/wpv-conditional]
      [wpv-conditional if="( '[show_related_domaines2]' eq 0 )"] Display something else [/wpv-conditional]

Use the new shortcode in [wpv-conditional] shortcode.

Test it in front-end:
hidden link
hidden link

Both work fine, please check if it is fixed, thanks

#1708771

This is awesome, thank you very much!

My issue is resolved now. Thank you!