I have added a php page (test.php) in my root directory (WWW) where wordpress is installed. I don't want to use the custom template method (add this page in my wordpress theme directory)
I have added in this php file this:
<?php
require('wp-blog-header.php');
get_header();
?>
<h1>Test</h1>
<?php
get_footer();
?>
When I do: www.example.com/test.php this page is correctly loading but the title of this page display "error 404"
I don't understand how can I resolve this problem.
you need to include wp-load.php to use header, in your case replace require('wp-blog-header.php'); with
<?php require_once('wp-load.php'); ?>
I have placed this code in my root directory in test.php file. This code is working fine if you replace require('wp-blog-header.php'); with require_once('wp-load.php');
Related
My wordpress is currently installed in the root at creativiii.com . I want to load wp-load.php from the folder /random-games/login/index.php
I cannot find a way to get to wp-load.php if I'm outside of my root. I tried with creativiii.com/wp-load.php, I tried with /var/www/creativiii.com/wp-load.php, and it just refuses to connect to the file and keeps giving me a HTTP ERROR 500.
I know the script I have works from the root, the problem is definitely with wp-load. How do I get this to work?
Here's the current contents of my very simple script
<?php
require( 'creativiii.com/wp-load.php' );
get_header();
echo 'new content outside WordPress';
get_footer();
?>
Try
<?php
define('WP_USE_THEMES', false);
require('./wp-load.php');
get_header();
echo 'new content outside WordPress';
get_footer();
?>
I have two side-menus on my Wordpress site that I have saved as php files. I am able to call these into my page.php file with the the following line of PHP <?php include("mobile-menu.php"); ?>
For some reason, I am unable to do the same in another of my page templates in a sub-folder. My template structure is fairly simple, in my main theme folder I have header.php, footer.php, mobile-menu.php etc. Then in a sub folder called "page-templates", I have another template called full-page.php. This is the template in which I am having trouble calling mobile-menu.php with the include function.
I have tried the following:
<?php include("../mobile-menu.php"); ?>
<?php include(__DIR__."../mobile-menu.php"); ?>
i have this code in my home.php-
<?php
include('PHPLiveX.php');
$ajax = new PHPLiveX();
$ajax->Ajaxify(array("applyJob"));
get_header();
?>
now i am moving this code to my header.php
include('PHPLiveX.php');
$ajax = new PHPLiveX();
$ajax->Ajaxify(array("applyJob"));
so that it will be available for all word-press file. but its giving me blank page(no error). i know that file is including because when i echo some content in the included file it shows in the page.the phplivex.php file contain a class which is used to ajaxify the theme. any guess wats causing the blank page?
You need to use complete real path of that file in-order to include it.
include('FULLPATHOFDIRECTORY/PHPLiveX.php');
FULLPATHOFDIRECTORY = has to be path to that directory which keep this file.
I think that you should use include_once() or require_once() when you call this file in header.php. Hope it helps.
U Go in your theme and in your active theme open function.php And Add this Code.
function.php
function IncludeFileFun(){
include('PHPLiveX.php');
}
add_action( 'init', 'IncludeFileFun' );
Note: PHPLiveX.php File is include in your active theme folde.
I am not seeing the content I have for the header region in my drupal theme is it best practice to use the following code in the page.tpl.php?
<?php include('region--header.tpl.php'); ?>
I see the content when I use the code above but I cannot see it when I use the code below:
<?php if ($page['header']): ?>
<?php print render($page['header']); ?>
<?php endif; ?>
In my .info file I have the following code:
regions[header] = Header
Copy your base region.tpl.php file to the theme's templates folder.
region--header.tpl.php file and region.tpl.php file should be placed in the templates folder.
I want to create a special php and javascript page, but I want it to use my Wordpress theme that is already installed. How to do that?
Thanks
You can do this by including the header and footer from wordpress, and putting your own code in the middle. Such as this:
include $_SERVER['DOCUMENT_ROOT']."/wp-blog-header.php";
include $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/[YOUR THEME]/header.php";
// your code goes here
include $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/[YOUR THEME]/footer.php";
I haven't tested this on newer versions of wordpress, but in the past that has worked. You can even include the wpconfig file if you want to use some of those variables, such as the database connection information.
Hope this helps.
See Integrating WordPress with Your Website « WordPress Codex on how to pull the header and other includes into a static php page/file, like:
<?php
require('/the/path/to/your/wp-blog-header.php');
get_header();
?>
<?php
define('WP_USE_THEMES', FALSE);
require('./wp-blog-header.php');
get_header();
query_posts('showposts=1');
get_footer();
?>