Can you have two Types in one Loop?


I am doing a database ‘search and replace’ for a Custom Content Shortcode shortcode - eg, [field title-link id=19] - that created links. This has worked well with the following Loop opener:

<Loop type=page id="{Get local=post_in}">

except I now realise that some of the links created using the above CCS code were for a custom post type with the slug ‘people’ so the Tangible template I created doesn’t work for these links.

My question therefore is, is it possible to create a Loop that covers both the page and people types in one Loop? I tried <Loop type=page,people id="{Get local=post_in}"> but that doesn’t work.

many thanks in advance

I think you can only specify one type for a loop because that affects everything that comes after it.

However, you can write a loop without a type, which will default to the loop type for that page/post/archive. So perhaps you can fix this by removing the type=page parameter.

It’s documented under ‘Loops without a specified type’:

Not the cleanest solution, but it’s also possible to use an If statement to activate a loop that fits the page type:

<!--Check if post-->
<If singular="post" type="post">
        <Field title />
    <!--Check if page-->
    <Else if singular="post" type="page" />
        <Field title />
    <!--Check if archive-->
    <Else if taxonomy="category,tag" />
        <Field title />
    <!--Report config issue-->
    <Else />
    <p>Type not configured.</p>

Thank you for your suggestions Phil. I still get nothing if I remove the type parameter. It still works for the page links but nothing is displayed for the custom post links. It doesn’t even work if I create a new template, just for the custom post type, like this:

<Loop type=people id="{Get local=post_in}">
  <a href="{Field url}">
    <If check="{Get local=link_text}" ><Get local=link_text /><Else /><Field title />

and then the shortcode in the text like this:

[template name="in-text-link-people" post_in=317 link_text="Person Name"]

Can you see anything wrong with this? As it works fine for the page links I am wondering if something inside the loop should be different for custom posts and so is breaking it?

Thank you for any further thoughts

Is your custom post type ‘people’ working with a loop at all?

Test with this:

<Loop type=people>
  <h1><Field title /></h1>

If the above does not work, then there is a problem accessing this post type, and it may not be configured properly.

Ah, no, it doesn’t! I’ll go back to the developer of the plugin I am using to check with them what the slug should be.

Many thanks for working that out for me Phil

1 Like

Have you tried.
<Loop type="page,people" id="{Get local=post_in}">

At least this works:

<Loop type="page,people" ><Field title /></Loop>

1 Like

Hi Ralf. I did try that (didn’t work), but I think the problem is with the type ‘people’ - I think I may have the wrong slug so I am just checking this with the Team Showcase plugin developer

Thanks for your suggestion though :slight_smile:

If it’s this one it might be team_member

There seems to be a few Team Showcase plugins but it’s this one: Team Showcase - Wordpress Plugin by cmoreira | CodeCanyon

I deleted my comment above because it was wrong. The solution to not include a type in the Loop does not work for the page or custom post type link. Apologies…

Have you confirmed the slug for your custom post type? That is essential before debugging anything else.

You should be able to see the slug in the URL when clicking on the feature in WP Admin.

For example the L&L template slug is tangible_template:

The best approach to debugging L&L is to get something simple working and add logic until it stops working, so you know where the issue lies.

I have a custom post type for galleries, and this loop works fine:

<Loop type="gallery" taxonomy="gallery_category" term="photos">
    <h1><Field title /></h1>

I recommend always using quotes around the values, even though this is mostly optional. :slight_smile:

Hi Phil. I have just heard back from the plugin developer and found out what the slug should be (it’s tshowcase in case anyone else needs to know). Now everything is working as you would expect. I’m so sorry for wasting people’s time (I’ve learnt a little lesson about troubleshooting with a simple Loop first to narrow down the issue).
Thanks for all your support


No worries, glad you got it working!