Can we have a php “page” without a WordPress “page”?

Well, inside your directory just keep a normal php file like my-page.php, and then create a vanity URL for it using .htaccess. Open your .htaccess file (if present in the nstallation directory) or create one

RewriteEngine On
RewriteRule ^my-page-slug my-page.php

Should be good

update

if you want to access WP posts and other objects, you must include “wp-load.php” and you can access regular $wpdb or $WP_query object. Here’s some sample code

<?php
//path/to/your/wordpress/installation/my-page.php

include_once ("wp-load.php");

$posts = get_posts();
foreach($posts as $post){
    echo $post->post_name;
    echo "<hr/>";
}

Leave a Comment