Type label of current Post

Hi,

I’m able to get the type name of the current Post using <Field type />, which outputs page if it’s a page.
But how do i get the type label: Page (with a capital)?

I love easy L&L questions! :smile: I mean I like difficult ones too, but it’s nice not to need to troubleshoot for hours to find an answer hahaha. You’re going to want to use the Format tag:

<Format case=pascal>
  <Field type />
</Format>
1 Like

Oops, I was too quick, I just realized that I didn’t quite answer your question. You weren’t looking for how to capitalize it, you were looking for the actual label. It looks like that doesn’t exist as a post/page field, and unfortunately the type loop doesn’t seem to allow setting a query parameter to only loop through the current post. Unless there’s some undocumented query parameter that I wasn’t able to find.

I was able to make this, which technically works, but it seems pretty unwieldy for such a simple task:

<Set type_name><Field type /></Set>

<Loop type=type>
  <If check="{Format case=lower}{Field label}{/Format}" value="{Get type_name}">
    <Field label />
  </If>
</Loop>

Hi @benjamin,

Ah ah, what a simple question can trigger.

I like your simple solution #1, it will do the trick given my Post Types have similar names and labels except the capital.

Applause for your solution #2, what an acrobatic! :grin:

1 Like

This does seem easy, but this doesn’t actually work. :o My label is something much different from the name, I cannot get the label to show for the type of the current post for the life of me.

I think the loop type called type, maybe better named “post type”, is what you want. Something like this:

<Loop type=type name=name_of_post_type>
  <Field label />
</Loop>

But looking at its documentation, there is no loop parameter name. That seems so basic I’m surprised it doesn’t exist yet.

As a temporary workaround, maybe you could loop through post types to find the one you’re looking for.

<Loop type=type>
  <If field=name value=name_of_post_type>
    <Field label />
  </If>
</Loop>
1 Like

This worked! Thank you!

1 Like

In the new version of the plugin, the name parameter can be used to get a single post type.

<Loop type=type name=name_of_post_type>
  <Field label />
</Loop>