Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute a custom php file with a wordpress website

I have installed wordpress blog in my domain(Ex: http://mywordpresswebsite.com). Now i have a php file called serve.php in the root like http://mywordpresswebsite.com/serve.php.

Now if i open the url in browser its saying page not found.

then i have added RewriteRule ^serve.php$ serve.php [L] in htaccess code, still its saying page not found.

Please give me a solution for this as soon as possible, thanks in advance.

like image 515
rkaartikeyan Avatar asked Jan 22 '26 10:01

rkaartikeyan


1 Answers

Wordpress templates are located in wp-content/themes/yourthemename/. Easy way to load a custom php file is to put serve.php in that folder and to make that file a page template by putting comment below at the beginning of the file:

<?php
/*
Template Name: Serve
*/

Now go to admin->pages, create a new page and assign that page template from the template dropdown. Open the http://mywordpresswebsite.com/serve/ url in browser ( click on Show Page in admin bar ) and serve.php will be loaded.

like image 126
Danijel Avatar answered Jan 24 '26 03:01

Danijel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!