Linking to page with single template

I have an archive of a CPT displaying on a page.

I want the title (text field) of the post to link to a page to hold the single template.

What do I need to set for the template conditions and for the link in the title to get this working?

So far I can only seem to load the single template for the CPT linked using the Title text without using the page.

Thanks

I guess I need to use the template element on the page I want my single cpt template to be displayed.

How do I pas the post ID to it so the CPT variables will populate?

Well, no help from the group here which was frustrating for me. In case it helps someone else, here is what I did to solve this.

I did seem to finally sort it out. I did the same exact things I did before and it failed but I added three steps that seems to have made the difference.

  1. I have updated to 1.7.2 and that MAY have had an impact.
  2. I reset the parameters for the link like for the 10th time (9 before the Bricks update).
  3. I AGAIN re-saved permalinks but I had done that also many times.

I spoke too soon.

I am able to load a single template directly but not to an instance of the template added to a page.

I really need help please.

What I am expecting to happen and what is actually happening are two different things.

When I used to hand code site, way back when :), I would ass the attributes to the URL and then the page would have access to those attributes while processing and rendering the page.

With Bricks, unless I am missing something here, this is not the case. If you refer to my image above that might help explain.

It seems the Bricks behavior is that even though I tell the link in the archive loop that the title say, is to link to a page and pass those attributes, this is not what occurs.

What happens on the page is that the single template is not receiving the post_id and so it shows empty data.

Why do I want to use a page to display the content of a post from the loop? Because I have options on the page that I want to use to conditionally show or hide elements from the single post on the page. For example, I could have multiple options for rendering the same data in a few different configurations with each their own styles.

The dialogue above in my example seems to indicate that I am passing the post_id to the template on the page but Bricks does not respond that way.

I am not sure if this is a unsupported feature, if so the dialogue above doesn’t make sense, or, a feature request, or, this is a bug.

Please Bricks team, take a look at this and let me know what I can do to make this work please.

Im not 100% sure I understood it right and am still on my first coffee haha but lemme give it a try.

Passing parameters from one page to another, I think, will only work either via query params in the URL which you then have to retrieve on the new page or some kinda setup involving localstorage. Wish wp had an easy global state like react.

You wanna show different sections/designs based on some attributes of the post right? I think the right approach for this would be to go back to using templates and then work with the conditions of where it is displayed.

Basically have multiple templates which are shown based on whichever attributes you’re using. I remember doing somehting like this with acf radio fields, haven’t tried it in bricks yet.

If this isn’t implemented in the conditions yet you might have to wait for the conditions api.

I’ll try n see if it works based on acf fields later today.

I am using ACF to create radio button selections for showing or hiding elements via conditions for elements.

The problem is link is not using the URL for the external page correctly and not adding the attribute for a template placed on a page to use.

Figure this out and I will buy the next cup of coffee :slight_smile:

I’m not 100% clear yet why it has to be a page instead of a template. Only reason I could think of is the url staying the same even though the content and/or design changes which makes it make even less sense for me haha. But then again I don’t know what exactly you’re building.

Template output/assignment via custom fields doesn’t seem to be implemented yet. You could always use a taxonomy for it though. If you add a category (or any custom taxonomy) you could create the various templates and output based on the assigned category.

It boils down to two things I think.

One, is that you can put those options on each entry for each post, test for that and effect the elements conditi0onally. I have actually done that.

The problem is that you have to enter that option for every post entry. If I put those option on a page, then the option effects every time a post from the archive is rendered. Therefore, I want to have the archive link send the post data to a page that renders the selected post.

See what I am saying now?

The second issue is, if you look at the UI I created a image of, the setting there look as though they should do just what I am saying, but they don’t. In fact, the URL doesn’t even look like one would think it should look like with those settings. It still says [path]/[cpt]/[post title] with no trailing attribute as defined in the UI.

This might even be a bug.

Hey @jmcbade, I do not understand your use case at all. :sweat_smile: But I tried my best to build (and explain) what you’re trying to achieve – at least from my understanding. Maybe it helps:

A very strange setup

2 Likes

I guess I came up with a scenario that has not been imagined before. :slight_smile: I create sites that are maintainable by the client without needing to use the Bricks Editor. I don’t even make them bother with Gutenberg. Gutenberg is not replacement for the power of Bricks.

With ACF, I am assigning a set of options for the client to choose one of a few layout options. I retrieve the selected value to use for showing or hiding a “combined” template with all the versions according to the layout option chosen for the page that is to display the single post data as selected from the archive.

ACF needs to have the selection for the field group associated with say a page, a post or a CPT.

If I use the template loaded for the single post of my CPT, I would have to store that Layout Selection with every post for that CPT. If I can associate it with the page I can set a layout style option for the page itself. The template then uses the selection to show or hide the element in the template according to the layout selection. The “catch” is that the template shown for the page has to use the data for the link selected in the archive loop.

In practice then, if I store the layout style with each cpt post, the usual way of linking using {post_link} works fine and I can use the layout setting to show / hide elements for that chosen post from the archive page, because the single post has the data for the post selected in the archive…

If I want the layout style applied and used for any/all posts as they are selected from the archive, and then pass the data for that select to a page with the template to be populated, I would have to do something like you demonstrated in your video.

The main (but not only) information you explained, is I can not use Bricks links configured the way I was, (see image from previous posts here), but how you explained in the video, leveraging (See 2:42 in the video). I still don’t understand what the “ref” is used for :). The custom code will be a requirement also if I want to accomplish my use case.

Here is an example of a possible selection box generated by ACF:

Select-Layout-Style

Can you see the my use case now? The overarching goal is that my client has some possible selections I can create for layouts but never needs to use the Bricks editor. to be used when displaying this single post.

Is this something the Bricks team can provide as a link configuration without any custom code in the future?

Thank you so much for your time to show me a way to do this now.

Very much appreciated

No, sorry. You probably explained it well. But I don’t get it. To be honest: I am not able to read it concentrated at the moment. :smiley:

If you want to know more about the rel attribute: HTML attribute: rel - HTML: HyperText Markup Language | MDN.

Going by the example screenshot of layout selections via acf I get what you’re after and I’m pretty sure it won’t be too long before you can render templates based on acf fields in bricks since you can do it in most other builders as well. Just gotta wait for the conditions api I guess.

Until then, I still feel like you could achieve the same by using custom taxonomies since you can use those in the conditions for the templates.

Another concern is (unless I understood wrong) that if multiple posts or whatever are rendered on one single page depending on query params n stuff, seo will suffer.

Again I might have gotten it all wrong but I feel like we’re over complicating a simple issue haha. It’ll be a little messy to add a lot of layout options via taxonomies but if you just got a few different ones it should be fine. Otherwise I’d just wait for the conditions api to come out.

I’ve got some sites I badly wanna build in bricks as well but gotta begrudgingly use my “old stack” just to be on the safe side, till a few things from the Roadmap are implemented.

@manc

The template would be used for only one post type to present the single post. Multiple section (containers, blocks - whatever), would be shown depending upon which “Style X” is selected.

Same single post data but presented differently depending upon the style choice.

IE: Maybe one style includes a featured image and another does not. Maybe one style has two columns and another does not. Maybe one have more detailed information (depending upon what field data was possible) or not.

I was looking at the Wordpress documentation and putting aside any “builder” it seems to say here that linking from a loop (archive of posts page to a page that is a single post is fundamental to Wordpress. Unless I just don’t understand, what I am trying to do - ie: sending from a loop to a single page presentation of a post is basic to Wordpress.

What am I missing here?

It feel like the builder is not natively supporting something, (I DO appreciate there is a way to get around it for now), very basic Wordpress but I could be missing something.

That’s exactly what happens when you create an archive template (or just a query loop somewhere on a regular page) and a single post template. Then you usually link from the archive / query loop to the single post.

What you are doing in your scenario is linking from an archive / query loop to an unrelated, static page.

I am not trying to be argumentative here - just trying to understand ok?

How is linking from a post in an archive loop to a single post from that loop “unrelated”?

How is that not just doing this: (From the WP Docs)

the_shortlink() – a link to the page or post using the url of the site and the ID of the post or page

Before page builders we just added the post_id to the end of the URL when linking and then used the URL’s post_id parameter to select the post to show.

If it’s “unrelated” I think it’s because we are not including the post_id when linking to the page - no?

Sorry if I am being thick here ok? But I just don’t get it (to quote someone I respect here :P)

Neither am I. Just trying to explain. :smiling_face:

You can still just use post IDs in the url. It all depends on your permalink setup in the WP settings. Usually you use pretty permalinks these days. And WP is then able to determine the post by „deconstructing“ the url.

As I said. You are linking from a post in a loop to a static page (trying to pass unrelated post information in some other way). The page you are linking to has its own ID / information and is unrelated to the post you are trying to pass and show in a nested template element.

If you „correctly“ linked to the related post you would just create and work with a single template for the specific post type instead of a static page (that has the single template included).

I have tried other link settings without any success.

When I look at the link from the archive to the page or the template, it’s unchanged.

It’s Bricks generating the URL from the link setting inside the editor.

Maybe I have to build something without Bricks to prove it to myself that the Wordpress docs are saying what I think they are saying, how I remember it working before so long ago. Maybe I will test with O2 also.

I need to see this for myself. :slight_smile:

Hi John,
Hi guys!

I have just skimmed the thread here, but due to the amount of information and answers, I am more confused than before. Can one of you summarise as simply as possible (if I were 5 years old) what this is all about?

:pray: