How to Create Custom Post and Page Templates in WordPress

Create Custom Post Page Templates wordpress

[vc_row][vc_column][vc_column_text]

Custom Page Templates

  • To create a new template for pages
  • Go into the theme folder of twenty-fifteen( found under wp-content/themes/twentyfifteen )
  • Create a copy of the file called page.php, and name it
  • Open it up with your favorite text editor

It should look something like this:

    • The first thing you want to do is add the following at the top of the code. Right below the PHP opening tag ( <?php )

    • So the commented area should look something like this:

  • With the code above added to the top of the code as a PHP comment
  • The template system of WordPress now recognizes this as a custom page template.
  • Go to your admin dashboard_add new/edit page section
  • You will see a new dropdown appear in the Page Attributes meta box on the right side
  • Now make the edits to the page template
  • You can edit anything in the code, as long as you have the Template Name: Roundup in the header

Custom Post Templates

  • It’s almost the same process, but you’ll need a plugin to work
  • There are two popular plugins, Custom Post Template and Single Post Template

With Custom Post Template Plugin

    • First, install it
    • Go to the page.php file and look for single.php
    • As we did for the page templates, make a copy of it, and name it
    • Open it with your favorite text editor
    • Should looks something like this:

    • Then add the following at the top. As  PHP comment.

    • After you added the php comment and installed the plugin, on the post editor, you should see a new meta box appear, titled “Post Template

    • With Single Post Template Plugin
    • Difference is the PHP Comment you have to add on the top

    • This one, adds the meta box under the editor, and not on the sides
    • Works the same as all the above

  • You can edit anything, add/remove anything
  • If you want to perform queries, you have to have either WP_Head() or wp_header() in your file

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text][Echo_Backend_SC post_id=”6646″][/vc_column_text][/vc_column][/vc_row]




    Full-Service Agency

    Here at PrefrCo, we’re on a mission to create opportunities for clients. We believe nothing is more important than partnerships that drive long-term business success. Our diverse team maximizes impact for our clients. We outthink the competition, not outspend them.

    It goes without saying that we’re big fans of purpose-driven design. We craft innovative digital experiences to give your customer’s the most effective interaction with your brand. We understand the time and effort it takes to build an audience in today’s digital world, which is why we value efficiency, security and custom solutions above all else.

    • Website Development 
    • Responsive Design
    • Website Accessibility
    • Search Engine Optimization
    • Hosting & Server Management
    • Email Marketing

    Looking to take control of your online social presence? Look no further. We’ll monitor your brand, industry and competitors and create relevant content that keeps your business ahead of the curve. All with the goal of gaining customer loyalty and confidence in your brand.

    • Platform & Reputation Management
    • Review Monitoring
    • Organic Posting
    • Paid Social Advertising

    Customized conversion tracking? Personalized analytics programs? Dedication to data-informed decisions? Check, check and check! Our in-house data team sifts through large data sets every day to provide our clients with valuable insights and the highest possible return on investment. In short, data drives everything we do.

    • Ad Tracking & Measurement
    • Custom Reporting & Analysis 
    • A/B Testing
    • Market & Industry Research
    • Conversion Rate Optimization