Skip Navigation

[Resolved] Parent-Child post relationship (previous ticket)

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

Problem:

Display content according to custom field values

Solution:

You can try wpv-conditional shortcode like this:

[wpv-conditional  if="( $(wpcf-jobsconnected-company-page-url) eq '' )"]
No Postions Posted
 [/wpv-conditional]

 [wpv-conditional  if="( $(wpcf-jobsconnected-company-page-url) eq '' )" evaluate="false"]
<a href="[types field='jobsconnected-company-page-url' output='raw'][/types]">Click here to view</a>
 [/wpv-conditional]

Relevant Documentation:

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional

This support ticket is created 6 years, 9 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 20 replies, has 2 voices.

Last updated by Luo Yang 6 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#627488
url location.PNG

Tell us what you are trying to do?

I was working on this with a Toolset supporter, but did not get back to the issue in time and it closed. Here is the thread: https://toolset.com/forums/topic/parent-child-post-relationship/

I am trying to get the "Single Booth" content template display hidden link;">Click here to view</a if no URL is submitted in the new booth form.

If a URL is submitted in the new booth form, I want that URL to display instead.

I looked into the sanitize filter (https://codex.wordpress.org/Function_Reference/sanitize_title), but I am not sure how to use it because I am not familiar with PHP and it seems like the post form takes html (perhaps toolset conditional statements take PHP? )

However, I did manage to use regular toolset conditional statements to get a result very close to what I am looking for. Basically, if a user doesn't input a URL for the company url field, it will automatically input their company url on our site

   [wpv-conditional if="( $(wpcf-jobsconnected-company-page-url) eq '#' )"]
   <a href="<em><u>hidden link</u></em>">Click here to view</a
    [/wpv-conditional]

However, if they have a URL to their own website, they can put that in and that URL will show.

   [wpv-conditional  if="( $(wpcf-jobsconnected-company-page-url) ne '#' )"]
   <a href="[types field='jobsconnected-company-page-url' output='raw'][/types]">Click here to view</a>
    [/wpv-conditional]

This almost works, but for some reason, if the leave the URL field blank, the

   [wpv-conditional if="( $(wpcf-jobsconnected-company-page-url) eq '#' )"]
   <a href="<em><u>hidden link</u></em>">Click here to view</a
    [/wpv-conditional]

seems to have an odd ending on the url

?cred_referrer_form_id=3110

but this does NOT happen if I simply stick the href link in the content template

 <a href="<em><u>hidden link</u></em>">Click here to view</a 

Thanks!

Is there any documentation that you are following?

Is there a similar example that we can see?

hidden link

   [wpv-conditional if="( $(wpcf-jobsconnected-company-page-url) eq '#' )"]
   <a href="<em><u>hidden link</u></em>">Click here to view</a
    [/wpv-conditional]
   [wpv-conditional  if="( $(wpcf-jobsconnected-company-page-url) ne '#' )"]
   <a href="[types field='jobsconnected-company-page-url' output='raw'][/types]">Click here to view</a>
    [/wpv-conditional]

What is the link to your site?
live site: hidden link

dev site: hidden link

#627622

Hello,

I have tested the URL you mentioned above:
hidden link

But can not see the problem you mentioned:
odd ending on the url
?cred_referrer_form_id=3110

And the link "Click here to view" is linked to URL:
hidden link

See screenshot: link1.JPG

Is this problem resolved?

If the problem still persists, please provide a test site with same problem, and fill below private detail box with login details and FTP access, describe detail steps to duplicate same problem:
How and where I can see the problem: cred_referrer_form_id=3110

I need a live website to test and debug, thanks

#629005

Thanks for the details, I can login your website, when the custom field "Jobs Connected Company Page" is empty, in shortcode [wpv-conditional], you will need to compare it with empty value '', for example, you can modify your codes as below:

    [wpv-conditional  if="( $(wpcf-jobsconnected-company-page-url) ne '#' ) AND ( $(wpcf-jobsconnected-company-page-url) ne '' )"]
   <a href="[types field='jobsconnected-company-page-url' output='raw'][/types]">Click here to view</a>
    [/wpv-conditional]
    [wpv-conditional  if="( $(wpcf-jobsconnected-company-page-url) ne '#' ) AND ( $(wpcf-jobsconnected-company-page-url) ne '' )" evaluate="false"]
   No Jobs Connected Company Page, here display something else
    [/wpv-conditional]

And test again

#630173

Thank you Luo, perhaps I did not explain it well, but this does not quite do what I need it to.

If the wpcf-jobsconnected-company-page-url is empty, I want the Jobs Connected job page automatically displayed. For example, since there is a Jobs Connected page for Emmaus Home, if a post is made titled Emmaus Home, I would like for the user to be able to leave the wpcf-jobsconnected-company-page-url empty and have the template automatically link to the page.

(For the dev site) The Emmaus Home Post should link to hidden link . Basically the default behavior is to display the Jobs Connected job page.

This code was an attempt for that :

 [wpv-conditional if="( $(wpcf-jobsconnected-company-page-url) eq '#' )"]
   <a href="<em><u>hidden link</u></em>">Click here to view</a
    [/wpv-conditional] 

When I tested with Emmaus Home, this did not seem to work.

However, if a company has their own job page they would like to display, entering a url in the wpcf-jobsconnected-company-page-url, would override this default behavior and make the "open positions" display the url/website that the company wishes- usually their own. The tests did work for when a url is entered.

hidden link

#630439

Your questions are not clear, Lets handle them one by one.

If the wpcf-jobsconnected-company-page-url is empty, I want the Jobs Connected job page automatically displayed.

As I mentioned above, If the wpcf-jobsconnected-company-page-url is empty, you will need to compare it with empty value '', not the value "#", why do you insist in using value "#" in your codes?
https://toolset.com/forums/topic/parent-child-post-relationship-previous-ticket/#post-630173

Since you did not point out where and how do you put the codes, so I tested it in a single "Booth" post:
hidden link

in the post content, use below codes:

[wpv-conditional if="( $(wpcf-jobsconnected-company-page-url) eq '' )"]
<a href="<em><u>hidden link</u></em>">Click here to view</a
[/wpv-conditional]

And, in custom field "Jobs Connected Company Page", the value is empty.

Test it in front-end:
hidden link

I can see the HTML code:

<a href="<em><u>hidden link</u></em>">Click here to view</a>

Please check if it is what you want.

#630652
getting booths to display jc pages automatically.JPG

Hi Luo,

Thank you for your patience. I am not a developer and have had to learn Toolset because the developer I hired was unable to use it correctly. Please bear with me if I make silly mistakes such as using value "#" in my code (it was not intentional).

With your help, I was able to get the Jobs Connected page to display if the URL is empty. However, for some reason, the message shows that no positions are listed. I am not sure what I am doing wrong. I am editing the single booth content template (hidden link).

#630767

I have done below modification, in your website:
1) Activate Views + Types plugin
2) Dashboard-> Settings-> Permalink, click "Save Changes" button
It seems that there are rewrite problem in your website, above two steps can fix them

3) Edit the content template:
hidden link
Change the codes to:

 [wpv-conditional  if="( $(wpcf-jobsconnected-company-page-url) eq '' )"]
No Postions Posted
 [/wpv-conditional]

 [wpv-conditional  if="( $(wpcf-jobsconnected-company-page-url) eq '' )" evaluate="false"]
<a href="[types field='jobsconnected-company-page-url' output='raw'][/types]">Click here to view</a>
 [/wpv-conditional]

Please test again, check if it is fixed or not, more help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional

#631115
Capture.PNG

Hi, this seems to have fixed it showing "click here" and "no positions", but now it only shows "no positions". The sample booth "diane's place" should only show "click here". For some reason, your code on the bottom right works.

hidden link

#631249

Above codes are only examples for how to use wpv-conditional, you can simple change the codes to:

[wpv-conditional  if="( $(wpcf-jobsconnected-company-page-url) eq '' )"]
There is not value in custom field "Jobs Connected Company Page", display some other URLs:
<a href="<em><u>hidden link</u></em>">Click here to view</a>
 [/wpv-conditional]

[wpv-conditional  if="( $(wpcf-jobsconnected-company-page-url) eq '' )"]
There is value in custom field "Jobs Connected Company Page", display field value:
<a href="[types field='jobsconnected-company-page-url' output='raw'][/types]">Click here to view</a>
 [/wpv-conditional]

Is it clear?
#631664

Hi, sorry, I am not sure what I am doing wrong. In the single booth content template (hidden link), I put the following code:

 [wpv-conditional  if="( $(wpcf-jobsconnected-company-page-url) eq '' )"]
<a href="<em><u>hidden link</u></em>">Click here to view</a>
 [/wpv-conditional]
[wpv-conditional  if="( $(wpcf-jobsconnected-company-page-url) eq '' )"]
<a href="[types field='jobsconnected-company-page-url' output='raw'][/types]">Click here to view</a>
 [/wpv-conditional]

which I think is the same code I am supposed to use except without the comments.

However, the "click here to view" shows twice. hidden link
I tried Activate Views + Types plugin and then going to Dashboard-> Settings-> Permalink, click "Save Changes" button which worked for you.

Is there still an error in my code or is it possible that this is a glitch?

#631740

I have done below modifications in your website:
1) Edit the content template
hidden link

Modify the codes to:

 [wpv-conditional  if="( $(wpcf-jobsconnected-company-page-url) eq '' )"]
<a href="<em><u>hidden link</u></em>">Click here to view</a>
 [/wpv-conditional]
[wpv-conditional  if="( $(wpcf-jobsconnected-company-page-url) eq '' )" evaluate="false"]
<a href="[types field='jobsconnected-company-page-url' output='raw'][/types]">Click here to v iew</a>
 [/wpv-conditional]

2) Test the post, without URL field value:
hidden link
I see this:

<a href="<em><u>hidden link</u></em>">Click here to view</a>

3) Create another post with URL field value "google.com":
hidden link
I see this:

<a href="<em><u>hidden link</u></em>">Click here to v iew</a>

Please check again, check if it is what you want? thanks

#631973
Page with issue.png
Perfect.png

Yes it is very close. The test the post, without URL field value works correctly.:
hidden link

However, the only problem is that, on the page with the google url, the "career fair page" text has changed from "Wayne State Virtual Career Fair" to "POST with JobsConnected Company Page URL". Can we make this still say "Wayne State Virtual Career Fair" and link back to the career fair page? I cannot find the change in the code, so I am unable to change it.

#632178

For the new question:
Can we make this still say "Wayne State Virtual Career Fair" and link back to the career fair page? I cannot find the change in the code

Please check the content template:
hidden link
You are using shortcode [wpv-post-link id='$fair'] to output the result.
It is for rendering the post link of parent "fair" post, so you can edit that test post:
hidden link
in section "Post relationship", option "This Booth belongs to Fair" choose parent fair post "Wayne State University Virtual Career Fair", and test again.

#639172

Thank you very, very much.

I have one last request.

As you know, when no url is entered under "open positions", a link is generated for the Jobs Connected company page. When there is a space in the name, for example "Diane's Place", Toolset generates the link as

<em><u>hidden link</u></em>

where a "-' takes the place of the space.

However, the way the Jobs Connected pages are structured is that a "%20" takes the place of the space and a "%27" replaces the apostrophe " ' " like this:

 <em><u>hidden link</u></em>

Is it possible to make it so that toolset will generate the url so that " ' " will be replaced with "%27" and so that " " will be replaced with "%20"?

Currently there is a "no page is found" message because the page links to hidden link

However, the link should go to hidden link

#641018

Since you are using shortcode [wpv-post-slug] in the codes, it is post slug of post, which produced by WordPress, for post tiele "Diane's Place", the post slug will be produced to "dianes-place" automatically by WordPress.

In your case, I suggest you use post title shortcode, for example, Edit the content template:
hidden link

Change this line from:

<a href="<em><u>hidden link</u></em>">Click here to view</a>

To:

<a href="<em><u>hidden link</u></em>">Click here to view</a>

And test again.

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-slug
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-title