Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1105110

    Hi,

    I’m developing a plugin and I have created Custom Post Type.
    For simplicity I want my clients to use the Advanced Layout Builder when they create these posts. I wanted to define a template for these posts so I created a single-map.php file (same name as my custom post) in my plugin directory and add this function to erase the default template for posts :

    add_filter('single_template', 'template_post_map');
    function template_post_map($single_template)
    {
                    global $post;
                    if ($post->post_type === 'map') {
                                   $single_template = dirname( __FILE__ ) . '/front/single-map.php';
                    }
                    return $single_template;
    }

    This function erase the default template of WordPress (with simple editor) but it doesn’t erase the default template of the theme when I activate the layout builder.

    I also tried to put my files in the child theme but it doesn’t work either. how can we do that ?
    Thanks a lot for your time

    Regards

    #1105998

    Hey leplusweb,

    Thank you for contacting us.

    Please refer to the documentation for function reference.

    Let us know if you have any questions.

    Best regards,
    Vinay

    #1106737

    Hi Vinay,
    Thx. I have already check the documentation but I didn’t find what I want to achieve. I have actived the Layout builder for my custom posts and it’s work fine.

    I want to define a template for all the posts which will be included in the front-end with the builder elements I use.

    Take the example of the portfolio, enfold has a file “single-portfolio.php”. I want to do the same for a custom post type. Example single-mycustompost.php.
    If I do this the file is well loaded but only when the builder page is disabled (simple wordpress mode). If I activate the Advanced Layout Builder the file is no longer loaded.

    Thanks for your time.

    Regards

    #1107121

    Hi leplusweb,

    I see, that only works when you use default editor.
    Once you activated the Layout Builder, you’re using template-builder.php file.

    Best regards,
    Nikko

    #1107479

    Hi Nikko,
    thx for your help, from now on we use the template_builder.php file in our child theme.

    We add what we want in this file and it’s work fine.

    Best regards

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘use layout builder with custom post’ is closed to new replies.