I have a page template, which is fully working throughout the website other than the pages where the plugin has generated a page such as a job description page, as the plugin that I am using is WP Job Manager. I have tried to include the php file in the functions of the theme and also the template of the theme however, nothing appears and if it does then the content of the template appears above the navigation bar?

Is there anyway in which I am able to get this into this page and any other page that is dynamically created via the plugin, as there will be many pages.

The plugin creates a Custom Post Type which is what is used to create the pages, the pages are not actually existing in the back end.

The plugin is located in the wp-content/wp-job-manager/... and the page template is located in the wp-content/themes/test-theme/universal-template.php

The code I have tried is <?php include('/wp-content/themes/test-theme/universal-template.php'); ?> I know this isn't the best way to include a file but I was doing this till I can get it working

  • 1
    Can you please put more effort in the question and give us code, files, etc that help us see your problem/question more clear and provide you with an accurate answer. Sep 20, 2016 at 14:16
  • I think we'd need a lot more information to attempt an answer to this. Does the plugin actually make Pages, or does it create Posts of a particular custom post type? Can we see any code you have tried? Sep 20, 2016 at 14:16
  • Question has been updated
    – miotk
    Sep 20, 2016 at 14:23
  • Can you paste the contents of template please? Sep 20, 2016 at 14:32
  • The contents of the template is just HTML to sit at the top of the page above everything else
    – miotk
    Sep 20, 2016 at 14:35

2 Answers 2


You can set the page template by calling update_post_meta() with a key of ‘_wp_page_template’.

Or while inserting posts, you can pass page_template to wp_insert_post().

See: https://developer.wordpress.org/reference/functions/wp_insert_post/#more-information


Using wp_insert_post() you can add a new post and use an existing theme.

  $new_page_id = array(
        'post_title'     => 'examplePage',
        'post_type'      => 'custom_post',
        'post_name'      => 'examplePage',
        'post_content'   => '',
        'post_status'    => 'publish',
        'post_author'    => get_user_by( 'id', 1 )->user_id,
        'menu_order'     => 0,
        // Assign page template
        'page_template'  => "/wp-content/themes/test-theme/universal-template.php"


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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