Skip Navigation

[Resolved] Need help with setting up search for CPTs

This support ticket is created 3 years, 7 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 44 replies, has 3 voices.

Last updated by jesseH-3 3 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#1821543

My question is how do I customize that code for multiple RFGs? And do I need both blocks of code?

#1824885

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jesse,

Do you mean if the Parent post has multiple RFG or if the Repeatable field group is from a different custom post type?

Please clarify for me.

Thanks,
Shane

#1824901

The parent post has multiple RFGs. I listed them in my post on 10/15.

#1825065

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jesse,

Then in this case the example Christian gave should cover this perfectly. You can check which group it is based on the slug like this.

[wpv-conditional if="( '[wpv-post-type]' ne 'rfg-slug' )"]
Show this content if the post type slug is not the same as the RFG slug<br />
Title: [wpv-post-title]<br />
Title with link: [wpv-post-link]<br />
Custom field from post: [types field="post-field-slug"][/types]<br />
[/wpv-conditional]
   
[wpv-conditional if="( '[wpv-post-type]' eq 'rfg-slug' )"]
Show this content if post type slug is the same as the RFG slug<br />
Title: [wpv-post-title item="@rfg-slug.parent"]<br />
Title with link: [wpv-post-link item="@rfg-slug.parent"]<br />
Custom field from RFG: [types field="rfg-field-slug"][/types]<br />
Custom field from parent post: [types field="parent-field-slug" item="@rfg-slug.parent"][/types]<br />
[/wpv-conditional]

In your case with the slugs added it would be


[wpv-conditional if="( '[wpv-post-type]' eq 'latest-model-row' )"]
Show this content if the post type slug is not the same as the RFG slug<br />
Title: [wpv-post-title]<br />
Title with link: [wpv-post-link]<br />
Custom field from post: [types field="post-field-slug"][/types]<br />
[/wpv-conditional]
   
[wpv-conditional if="( '[wpv-post-type]' eq ' prev-revision-row' )"]
Show this content if post type slug is the same as the RFG slug<br />
Title: [wpv-post-title item="@rfg-slug.parent"]<br />
Title with link: [wpv-post-link item="@rfg-slug.parent"]<br />
Custom field from RFG: [types field="rfg-field-slug"][/types]<br />
Custom field from parent post: [types field="parent-field-slug" item="@rfg-slug.parent"][/types]<br />
[/wpv-conditional]

[wpv-conditional if="( '[wpv-post-type]' ne ' prev-revision-row' OR  '[wpv-post-type]' ne ' latest-model-row' )"]
Show this content if post type slug is the same as the RFG slug<br />
Title: [wpv-post-title item="@rfg-slug.parent"]<br />
Title with link: [wpv-post-link item="@rfg-slug.parent"]<br />
Custom field from RFG: [types field="rfg-field-slug"][/types]<br />
Custom field from parent post: [types field="parent-field-slug" item="@rfg-slug.parent"][/types]<br />
[/wpv-conditional]

Please let me know if this helps.
Thanks,
Shane

#1825215

Thanks, can you please double check your code. I am guessing you meant the second conditional to be a duplicate of the first (except with the RFG slug changed) but that is not the case.

I need to know how to customize the 3rd conditional for the two RFGs. You've done that in the first line of the 3rd conditional, but how do I do it in this line? Title with link: [wpv-post-link item="@rfg-slug.parent"]
(Please provide the code using actual slugs instead of rfg-slug since much of the confusion here is how I should incorporate two different slugs)

(Note that I'm only looking to output the title with link, so I'm omitting the lines that output the title and the custom fields, at least at this point.)

#1825297

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jesse,

The first 2 conditionals are meant to be as they are.

The first one is to target only the "latest-model-row" RFG and the second one is only to target "prev-revision-row".

The 3rd condition is to target any Posts that the archive is displaying that is not from any of the above 2 conditionals.

"@rfg-slug.parent" is referring to the slug of the repeatable field group where you should replace it with the actual slug. An example would be @prev-revision-row.parent

Most times we can't provide with the actual slugs given that in most cases we don't know what the actual slugs are unless they are provided.

The conditionals are only meant so that you can target your post types individually.

Please let me know if this provides some clarity. Also are you getting any output with the conditionals added?

Thanks,
Shane

#1825319

I have provided the actual slugs, and you even used them in your code: latest-model-row & prev-revision-row

So please tell me how to update the third conditional – without placeholders! – to output results for both of these RFGs. If they need to be split into two conditionals to do so, that is fine.

Regarding the first two conditionals, again, it sounds like they should be identical with the exception of the rfg slug. But they are not – one says "if the post type is the same" and the other says "if the post type is NOT the same" – and the outputs differ.

This is getting incredibly frustrating. I have provided all of the information you're referring to, along with login access to the site, but I continue to not get the information I am requesting. Is Christian available? He seemed to have a good understanding of what I am trying to do. Please let me know if he is able to look at this ticket instead.

#1825325

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jesse,

"So please tell me how to update the third conditional – without placeholders! – to output results for both of these RFGs. If they need to be split into two conditionals to do so, that is fine."

The third conditionals is for posts that are for Neither of your RFG. Given that this is a general search i'm assuming posts from other Post types will be displayed here as well, unless the archive is limited to only these 2 repeatable field groups. So any Posts that aren't apart of the Repeatable field group will be displayed using the 3rd conditional

Regarding the first two conditionals, again, it sounds like they should be identical with the exception of the rfg slug. But they are not – one says "if the post type is the same" and the other says "if the post type is NOT the same" – and the outputs differ.

They are meant to be Identical but they are targeting different RFG, so conditional 1 is being used to display all the RFG with the slug "latest-model-row"

The second conditional is for picking out RFG with the slug "prev-revision-row"

What I should've done was to remove these texts "Show this content if the post type slug is not the same as the RFG slug<br />" and "Show this content if post type slug is the same as the RFG slug<br />"

Perhaps this is where the conditional lies.

This is getting incredibly frustrating. I have provided all of the information you're referring to, along with login access to the site, but I continue to not get the information I am requesting. Is Christian available? He seemed to have a good understanding of what I am trying to do. Please let me know if he is able to look at this ticket instead.

I can understand the frustration but the solution i'm providing is from where Christian left off. I've initially asked you if the conditionals are displaying the correct item.

At this point I understand you want to customize how the RFG are being displayed which is what the conditionals are meant to do. So I need to know if the conditionals are displaying the Correct information, if not then can you provide me with the link to the page where I can have a look because the link you've provided in the private field is returning a page not found.
hidden link

I'm under the impression that the only thing left is to customize the output.

Perhaps we can look at it link that.
Thanks,
Shane

#1825327

Okay, I just dove in and starting trying a bunch of different things. Here is what I have:

[wpv-conditional if="( '[wpv-post-type]' eq 'prev-revision-row' )"]
Show the parent content if post type slug is prev-revision-row: [wpv-post-link item="@prev-revision-row.parent"]
[/wpv-conditional]

[wpv-conditional if="( '[wpv-post-type]' eq 'latest-model-row' )"]
Show the parent content if post type slug is latest-model-row: [wpv-post-link item="@latest-model-row.parent"]
[/wpv-conditional]

[wpv-conditional if="( '[wpv-post-type]' ne 'prev-revision-row' OR  '[wpv-post-type]' ne 'latest-model-row' )"]
Show this content if post type is not either of the RFGs: [wpv-post-link]      	
[/wpv-conditional]

This works correctly whether I'm searching for data in prev-revision-row RFG, latest-model-row RFG, or data outside of those two WITH THE FOLLOWING EXCEPTION:
The third conditional outputs a link to the RFG if I search for data in an RFG.

So, my new and hopefully final question is: what change do I need to make to this code so that the third conditional only outputs a link for data that is not in an RFG?

#1825329

Sorry, looks like we both responded at the same time! Hold on while I review your response and I will get back to you.

#1825331

The page you linked to will only work if you are logged in.

Regardless, I think it's best if we skip to the code in my post above, and the bolded question.

#1825339

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jesse,

I managed to find the search page and had a look at the conditionals. So far everything is working correctly from what i've tested.

[wpv-conditional if="( '[wpv-post-type]' eq 'prev-revision-row' )"]
Show the parent content if post type slug is prev-revision-row:
[wpv-post-link item="@prev-revision-row.parent"]
      
[/wpv-conditional]

[wpv-conditional if="( '[wpv-post-type]' eq 'latest-model-row' )"]
Show the parent content if post type slug is latest-model-row: [wpv-post-link item="@latest-model-row.parent"]
[/wpv-conditional]

      [wpv-conditional if="( '[wpv-post-type]' ne 'latest-model-row' ) AND ( '[wpv-post-type]' ne 'prev-revision-row' )" ]
    
Show this content if post type is not either of the RFGs: [wpv-post-link]    
    
[/wpv-conditional]

The only thing that is needed is to add the content that you want to display in each section.

Hopefully this clarifies the issue. Also i'm able to confirm that the archive doesn't only display the 2 RFG but other posts as well, which will be handled by the 3rd conditional.

Perhaps we need to take it a step at a time with just 1 conditional at a time.

For this one below that should display for pre-revision-row, what exactly do you want to display

[wpv-conditional if="( '[wpv-post-type]' eq 'prev-revision-row' )"]
Show the parent content if post type slug is prev-revision-row:
[wpv-post-link item="@prev-revision-row.parent"]
      
[/wpv-conditional]

Thanks,
Shane

#1825353

They all work correctly, and output the correct thing, except the third one outputs every time, whether I'm searching for data in an RFG or not.
Try these search terms:

GKGADCA
(this is data that exists in latest-model-row)

GABLARA
(this is data that exists in prev-revision-row)

Legend
(this is data that is outside of both of those RFGs)

And I think you'll see what I mean.

#1826159

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jesse,

Thank you for the sample information. I was able to adjust the 3rd conditional using this.

Please check on your end now and let me know if the desired results are appearing for you now.

Thanks,
Shane

#1827513

Got it. You changed OR in the conditional to AND.

[wpv-conditional if="( '[wpv-post-type]' ne 'prev-revision-row' ) AND ( '[wpv-post-type]' ne 'latest-model-row' )"]
Show this content if post type is not either of the RFGs: [wpv-post-link]      	
[/wpv-conditional]

Everything works correctly now.

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