Create custom post loop layouts

Hello bb guys,

I have a question regarding the layout of post (specifically custom post types).

I would ideally like to be able to use the builder to create each post, then have a loop to pull through the relevant ones. eg. A new post type called Research Posts. Then a Page called Research, that will have page specific heading and footer built with bb. The main content will have have a module that pulls in the posts.

Here are the options:

  1. I have tried to use feed as the layout style to achieve this but the loop only renders a striped down version with no columns, images (not featured but added with module on the page/ post builder ) and removed formatting.

  2. I have tried to use an external plugin (the loops) to create a loop with a layout template I can edit in php. This look great except the builder layout is removed (images, not featured, are passed.)

  3. I have create custom post type with afc to add custom fields, this way I can create a post layout based on with the loops plugin and put the loop generating shortcode onto the research page. However, this is a fixed template and does not allow for the od (every 10 or so) posts that are full width and not 60/40 coloumns.

Any suggestions?

I will try to push to the server tomorrow so you can have a look but from the description I have given can you advise a way to include a loop of posts that have been created with the bb editor?

Thanks, Vincent

Hey Vincent,

I think the issue is that the builder looks at the main query to see what posts it needs to include assets for. It sounds like you’re creating a secondary query which runs after wp_head so the builder doesn’t see those posts.

We do have a filter fl_builder_global_posts that helps with this, but it sounds like that might not be an adequate solution for you.

You might consider looking at pre_get_posts to hook the posts you need into the main query.

I would be happy to have a look at the site once you get it up if you would like. Let me know.

Justin

Hi Justin, Thanks for that update the second query sounds like the problem.

I think the best thing to do is to create a new module, similar to the default posts module but with more layout options. When I have the time I will try to create one.

In the mean time I have found a simpler solution… Creating a new wysiwyg custom field (ACF) and using this as an advanced excerpt, leaving the main post content available to edit via the page builder. My question is, can I add the page builder to a custom field?

This way, the client can create a layout for the excerpt (preview in this example) that will show in the archive list and then create the full post also with the builder.

Screen shot

Thanks for the help, Vincent

Hey Vincent,

The page builder already saves its data to a custom field (_fl_builder_data), so my guess is that having it act on an ACF field probably won’t work. It really only works on a per post basis, so you would probably be looking at a custom post type for the advanced excerpts if you wanted to make this happen.

Justin

Hi Justin,

not quite sure I follow. Do you mean create a custom post type with attached advanced custom field and assign somehow the builder (_fl_builder_data) to the custom post type via the settings and the custom field via a new module?

OR

Do you mean create a new custom post type specifically for the preview/archive layout and another for the post content and some how (not sure how to do this programmatically) link the preview to the article.

Thanks for the info, Vincent

Hi Vincent,

Do you mean create a new custom post type specifically for the preview/archive layout and another for the post content and some how (not sure how to do this programmatically) link the preview to the article.

That’s what I meant. Just throwing out ideas as I’m not sure how you would do this programmatically either. After thinking about it some more, your best bet is probably going to be to code a custom module that displays the archive layouts in a way you want.

Sorry I can’t be of more help here.

Justin

Not Justin,

not to worry. I also think the custom module is a good way forward. I will try to get something together as soon as possible.

Thanks, Vincent

** Hi Justin, dont know why that says Not just…!? **

No problem, Vincent! :slight_smile: