Featured Post Today
print this page
Latest Post

How to add custom PHP Page or PHP Code in Wordpress?

PHP Code in Wordpress

How to Add PHP Code in WordPress Posts and Pages (Without Plugins)

By default, WordPress does not allow PHP code execution inside posts or pages for security reasons. However, if you need to add custom PHP functions without relying on plugins, follow this simple method to integrate PHP into your WordPress content.


Method: Using a Custom Template File

Step 1: Duplicate an Existing Template File

  • Navigate to your WordPress theme folder:
    wp-content/themes/your-theme/
  • Copy and duplicate page.php or single.php
  • Rename the duplicate file (e.g., custom-template.php)

Step 2: Modify the File Header

Open the newly created custom-template.php file and add the following lines at the top:


 <?php  
 ///////////////////////////////////////
 // File Name: FusionMarketPro.Online //
 ///////////////////////////////////////
 ?>  

4) This will allow WordPress to recognize it as a custom template.

Step 3: Add Your PHP Code

Inside custom-template.php, you can now insert your PHP functions anywhere within the content structure:

 <?php  
    echo "Hello, this is a custom PHP function in WordPress!";
?>

Step 4: Assign the Custom Template to a Page

  1. Create a new page or post in WordPress.
  2. In the Page Attributes section (right sidebar), select "Custom PHP Template" from the Template dropdown.
  3. Publish or update the page.

Benefits of This Method

✅ No need for additional plugins
✅ Direct control over PHP functions
✅ Customizable for advanced functionality

This approach is ideal for developers who want greater flexibility while maintaining WordPress security best practices.

0 comments

Date List Static Array with PHP Function Drop Down

Date List Static Array with PHP Function Drop Down :

Date list static array can help you to design contact form in offline mood. With this code, you can add dates in your form without using API system.

 <?php   
      $date = array(   
      '1'=>'1',  
      '2'=>'2',  
      '3'=>'3',  
      '4'=>'4',  
      '5'=>'5',  
      '6'=>'6',  
      '7'=>'7',  
      '8'=>'8',  
      '9'=>'9',  
      '10'=>'10',  
      '11'=>'11',  
      '12'=>'12',  
      '13'=>'13',  
      '14'=>'14',  
      '15'=>'15',  
      '16'=>'16',  
      '17'=>'17',  
      '18'=>'18',  
      '19'=>'19',  
      '20'=>'20',  
      '21'=>'21',  
      '22'=>'22',  
      '23'=>'23',  
      '24'=>'24',  
      '25'=>'25',  
      '26'=>'26',  
      '27'=>'27',  
      '28'=>'28',  
      '29'=>'29',  
      '30'=>'30',  
      '31'=>'31');   
 ?>   
  <html lang="us-en" xml:lang="us-en">   
   <head>   
       <style>   
         .form{   
            margin:10px auto;   
         }   
         .form label, select{   
            display:inline-block;   
            float:left;   
         }   
         .form label{   
            width:75px;   
         }   
         .body{   
            width:250px;   
            height:50px;   
            background-color:#C33;   
            padding:20 20 20 20;   
            margin:300px auto;   
         }   
    </style>   
   </head>   
   <body>   
     <div class="body">   
     <form class="form">   
       <div><label for="dates"><b>date:</b></label></div>   
        <div><select name="date" id="dates">   
                 <?php   
         foreach($date as $dates => $datenow)   
         {   
          echo'<option value="'.$dates.'">'.$datenow.'</option>';   
         }   
        ?>   
            </select>   
              </div>   
         </form>   
    </div>   
    </body>   
  </html>   

0 comments
 
Copyright © 2011-2026. Samee Articles - All Rights Reserved
Proudly powered by Blogger