Customizing: Adding PHP Pages
Sometimes you want to have a PHP page that can be accessed via your WordPress site and in fact looks like it is a part of the website. You do not have to use any of the hooks or filters. This is probably the easiest way to integrate custom code into a WordPress site.
- Duplicate the post.php or page.php file in your theme folder. For LabCatsCoding, this is located at /wp-content/themes/bb-theme-child.
- However, because we use a child theme, we need to copy the file from /wp-content/themes/bb-theme folder to my /wp-content/themes/bb-theme-child folder
Here is what that file looks like
<?php get_header(); ?> <div class="fl-content-full container"> <div class="row"> <div class="fl-content col-md-12"> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); get_template_part( 'content', 'page' ); endwhile; endif; ?> </div> </div> </div> <?php get_footer(); ?>
- Remove the code between the two inner PHP tags so it looks like this:
<?php get_header(); ?> <div class="fl-content-full container"> <div class="row"> <div class="fl-content col-md-12"> <?php // Here's where you write your PHP code! ?> </div> </div> </div> <?php get_footer(); ?>
- Then, add these three lines below to the top of your file.
<?php /* Template Name:UserProfile */ ?>
- Finally, create a new Page and select the template to match the template name given to your PHP page

- When you go to the URL of the new page – it will run your PHP code and display in the style of your website.
