-
AuthorPosts
-
May 29, 2019 at 12:10 pm #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 timeRegards
June 1, 2019 at 8:04 am #1105998Hey leplusweb,
Thank you for contacting us.
Please refer to the documentation for function reference.
Let us know if you have any questions.
Best regards,
VinayJune 3, 2019 at 3:59 pm #1106737Hi 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
June 4, 2019 at 2:57 pm #1107121Hi 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,
NikkoJune 5, 2019 at 11:18 am #1107479Hi 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
-
AuthorPosts
- The topic ‘use layout builder with custom post’ is closed to new replies.