V
V
Vyacheslav2015-10-20 18:14:50
WordPress
Vyacheslav, 2015-10-20 18:14:50

How to pull a wp theme on a php file?

There is a php file not related to wordpress. It is located, for example, in the mysite/page/index.php folder
Content (it doesn't matter what)
"Example text"
When you navigate to http://mysite/page in the browser , the content should be displayed instead of the blog feed. all elements of the theme must be present.
Can anyone tell me what kind of framework will be for such a file?
Updated ....
Shl.
When adding

<?php 
define('WP_USE_THEMES', true);
require('../wp-blog-header.php');
?>

Topic is showing but 404 page template is showing

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Golubev, 2015-10-20
@noxiconum

The standard task is to make a new template and apply it to a new page created in the WP admin.
There are a lot of detailed articles on the Internet on this process: https://wpcafe.org/tutorials/kak-sozdat-svoy-shabl...
WP will direct you to the template file, you can specify anything you want in it.
for example

<?php get_header(); ?>
  
    <div id="primary" class="site-content">
        <div id="content" role="main">

Место которое нужно вам
  
        </div><!-- #content -->
    </div><!-- #primary -->
  
<?php get_sidebar(); ?>
<?php get_footer(); ?>

S
Super User, 2015-10-22
@sergeystepanov1988

I have the file in the theme folder, but the bottom line is that you need to include wp-config.php, not wp-blog-header.php and after that make several calls to the methods of the $wp object so that the code does not give 404 to any request :

error_reporting(E_ALL);
ini_set( 'display_errors','1'); 

$current_directory = realpath(dirname(__FILE__));
define('WP_USE_THEMES', true);
require_once($current_directory . '/../../../wp-config.php'); 
$wp->init(); 
$wp->parse_request(); 
$wp->query_posts(); 
$wp->register_globals(); 
$wp->send_headers();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question