Custom Modules with Custom Field Rendering in a Layout Template

About this forum
These forums have not been active for several years. They're available for search and reference, but a lot of this information is likely out of date.

For current information, try visiting our Knowledge Base.

Home / Support / Custom Module Development / Custom Modules with Custom Field Rendering in a Layout Template

This topic is: resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #113154

    Stephanie
    Participant

    Hi there!

    This question is a little hard to explain, so please bear with me.

    I am trying to find a way to integrate Beaver Builder with WP Toolset Types and Views in order to generate BB Layout Templates that replace the single pages of a custom post type called “Products.”

    My “Products” custom post type contains several custom fields that I would like to display using custom modules and a Layout Template that gets applied to all of my Products. I have already made some custom BB modules that display the post title and custom fields for this post type. I have also created a BB Layout Template called “Product Single Layout” and placed my custom modules within it.

    In order to apply this Layout Template to all of my Products without having to go into each single page, open Page Builder, and manually select it, I have looked into rendering BB Layout Templates using shortcodes. Since the Toolset plugin contains a Content Template feature that overrides the default single.php layout for my custom post type, I have placed the following shortcode inside of a Content Template called “Products Single.”

    [fl_builder_insert_layout slug=”product-single-layout” type=”fl-builder-template”]

    So far, this works well in that it renders the Layout Template for all of my products without needing to go into each one and select it. The problem is that my custom modules are not working in relation to each Product. Instead the single product pages still display the title and fields of the Layout Template itself and do not update to reflect the title and fields of the Product it is getting applied to. However, when I open Page Builder for a single product, then the modules suddenly start to work well and render the correct content.

    My question is, is there any way to create a Layout Template with custom modules that render post fields and have this content get rendered for each of my posts without having to go into PageBuilder and publish each individual post?

    This is a tough one to explain, so I am happy to fill in some details or provide access to my site if needed.

    Thanks!

    #113290

    Ben Carlo
    Keymaster

    Hey Stephanie,

    I’ve already assigned another member of the team to assist you with your concern.

    Ben

    #113469

    Justin Busa
    Keymaster

    Hi Stephanie,

    Thanks for the detailed info. We’re actually working on some pretty cool stuff that should make doing that much easier, but unfortunately, that won’t be ready until later this year. For now, this is the example I have given out before that did the trick (doesn’t use Toolset). Have a look at this and let me know if it helps…

    With this example, you should be able to create a Beaver Builder template that has a section for the editor content and is applied to all single post pages.

    Post Content Module
    This is a quick little module that doesn’t do anything but echo the content for the post in the main loop. You can use this to build a template and then choose where the editor content will be displayed.

    single.php
    This is an example of how you can render a builder template within a theme template file (in this case single.php).

    functions.php
    This filter is needed to enqueue the assets for your template on single post pages.

    The key here is really in the example module’s frontend.php file. In that you’ll see were using the global $wp_the_query to get post data from the main post, not the template post.

    Let me know if you have any questions.

    Justin

    #114573

    Stephanie
    Participant

    Hi Justin,

    Thanks so much for the detailed post and example. I was able to use the files to get the functionality I was looking for.

    I ended up creating separate modules for the post title and post content, and I also created a module that accepts a custom field slug via a text field in the module settings and displays the selected field’s corresponding content.

    Very handy! Thanks again for posting this.

    #114610

    Justin Busa
    Keymaster

    Hi Stephanie,

    That’s great! I’m glad to hear the examples helped!

    Let me know if you run into anything else.

    Justin

Viewing 5 posts - 1 through 5 (of 5 total)

The forum ‘Custom Module Development’ is closed to new topics and replies.