0


I am creating a page using the wp_insert_code the page is being created just find.

I want to choose a default template for the page I am creating which the template is inside plugin folder in a templates folder.

I tried to use this code:

update_post_meta($post_id, '_wp_page_template', $page_template_path);

It does work when ever a template in defined inside the theme directory but I want to have templates files inside plugin folder.

To make my plugin reusable and easy to setup. Can you help me figure that out?

0

Here is your answer. Go to this GitHub repository and follow the instructions.

  • Seriously man, have you read his full post? And this is not a plugin man. This is a class which he can use in his plugin. Read his full post then read the git repo description and then comment please. @Charles – CodeMascot Sep 6 '16 at 16:36
  • Answers should contain contextual links but not be bulk of the answer. Everything the user needs should be included and explained in an answer. The reason for this is links can be removed or moved by the author and the answer would no longer be valid. Please review "How to write a good answer" in the Help Section. – Howdy_McGee Sep 6 '16 at 17:00
  • With all due respect, have you read the whole question and the link I've given ?? Is there any reason to write the full class documentation where this is already there in the link ? I don't think so. So I gave him the link and told to follow the instruction. And writing the whole documentation here also cause complexity I think. But that is exactly the answer he needed. I already gone through the problem and I solved it using this class. He could've told me to clarify the answer. The downvote is totally unnecessary here. Thanks for your review. @Howdy_McGee – CodeMascot Sep 6 '16 at 17:07
  • Hi, It doesn't seem to be fixing my problem actually you didn't understand my question quite right. I need my template files to be in my plugins folder not theme folder otherwise it would be easy to create files in theme directory which is not my goal. – MMT designer Sep 8 '16 at 8:35
  • You've not read this carefully. Got to the GitHub repository and use the class to instantiate the template files which you want to load. This class loads template files form plugin folder as themes template and this is its purpose. Please read the GitHub repo documentation carefully. @MMTdesigner – CodeMascot Sep 8 '16 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.