Post Type in Conditions

Hi,

Bricks very usefully allows querying multiple post types with the query loop. To compliment this, could a condition of Post Type be added to the choices when setting up an element condition?

In my use case I want to add an extra image to a card for posts of type A, but not type B.

7 Likes

use ā€œget_post_type()ā€ in php function of condition:

{echo:get_post_type()}

and name of ā€œyour_post_typeā€

2 Likes

@WeLoVeBricKs thanks for that, although this is a feature request not a how to request

I need to be able to use condition to show some element when a session variable has a certain value.
E.g. $_SESSION[ā€˜Loggedā€™] != ā€œNOā€.
how can I implement it?

Mmmmh, what kind of application can you think of?
I was unsure for a moment (and the condition is not there, youā€™re right), because in general you define the structure of the post type via the template and in it you can define further elements (but the condition post type is already fulfilled).
I can also define sections as template and define the custom posttype as condition.
I just canā€™t think of an area of application right now. What was your idea? :slight_smile:

1 Like

Hey Sebastian, as I said in the OP, this request came about because I had a query loop querying two post types and I wanted to show an element for one type but not for the other. So itā€™s not relating to a page template but a query loop querying more than one post type.

Hope that clarifies!

1 Like

Then I got you wrong. My bad!
A very specific request but yes it would be nice if that would be possible!

I have no idea how to build something like this ui based, because the conditions in general are above the query loops and apart from the taxonomy filters this would be a whole level lower.

I like the idea anyway! :slight_smile:

1 Like

Is it that specific? Iā€™m making a Search Results template for a site that has both blog posts and products. It would be great to have buttons for ā€œRead moreā€ or ā€œAdd to cartā€ only appear for the relevant post type instead of both.

This seems like something would be a fairly common occurrence so Iā€™m surprised itā€™s not easily doable.

Itā€™s weird but that way is not working for me now (Iā€™m using it inside a listing template from jet engine)
Even if a put that fuction inside a basic text I donā€™t see nothing.

Because Iā€™ve a clean and seo friendly permalink config Iā€™m using post link or post url to see which CPT is

This feature is imperative. Very frustrated not to have this available. Post type is not even available as dynamic data. Mind-boggling.

Not ā€œPHP Functionā€ nor anything similar appears in the condition menu for an element. Perhaps it does if Code Execution is enabled? If that is the case, should not need that in order to display elements based on post type.