• 0

PHP in Wordpress pages


Question

Hello,

I have a database that uses php to gather the the info from a mysql database and then display it in a table.

How do I get this to show in wordpress? I have 11 .php files that I need to show on in wordpress site. Is this possible and how?

I asked on the wordpress forums and they told me to use page templates - http://codex.wordpress.org/Pages#Page_Templates

But I have no idea what I'm supposed to do to get it to work. :(

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0

I'm having a massive problem with this, I tried entering the code into the top of the files but it just looks the same. Just shows me the links/table on a white background, no sign of my wordpress site.

This is how my index file looks

<?php 
/* Short and sweet */
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<p><a href="dataentry.php">Enter Season Data</a></p>
<hr />
<p><a href="season.php">Season Stats (View all)</a></p>
<p><a href="players.php">Player List</a></p>
<p><a href="managers.php">Manager List</a></p>
</body>
</html>

Link to comment
Share on other sites

  • 0

Is Wordpress located in your root folder? Remember that where you're wp-blog-header.php file sits is how you should be calling it.

Example: If your main site (php based) is in a root folder and Wordpress is under /cms/, then it should be /cms/wp-blog-header.php.

Link to comment
Share on other sites

  • 0

No its not in root, but my php files in the same directory as wordpress, the same place as wp-blog-header.php. have now tried this and got the same result - no change.

<?php
require('./wp-blog-header.php');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<p><a href="dataentry.php">Enter Season Data</a></p>
<hr />
<p><a href="season.php">Season Stats (View all)</a></p>
<p><a href="players.php">Player List</a></p>
<p><a href="managers.php">Manager List</a></p>
</body>
</html>

Link to comment
Share on other sites

  • 0

You still are not linking it correctly. The ./ tells it to go back to root.

You should be just using 'wp-blog-header.php' if your PHP files and WordPress exist in the same directory.

Link to comment
Share on other sites

  • 0

You still are not linking it correctly. The ./ tells it to go back to root.

You should be just using 'wp-blog-header.php' if your PHP files and WordPress exist in the same directory.

Ok, changed and got the same result. :(

<?php
require('wp-blog-header.php');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<p><a href="dataentry.php">Enter Season Data</a></p>
<hr />
<p><a href="season.php">Season Stats (View all)</a></p>
<p><a href="players.php">Player List</a></p>
<p><a href="managers.php">Manager List</a></p>
</body>
</html>

Link to comment
Share on other sites

  • 0

What about Exec-PHP or one of the other Wordpress PHP plugins? I use Exec-PHP that allows me to put the PHP in a post or page. I pull data from a MySQL db and display it in a table using this method.

Link to comment
Share on other sites

  • 0

What about Exec-PHP or one of the other Wordpress PHP plugins? I use Exec-PHP that allows me to put the PHP in a post or page. I pull data from a MySQL db and display it in a table using this method.

I tried that yesterday and was getting errors.

Link to comment
Share on other sites

  • 0

Please try not to edit your posts; I get a subscription and I want to reply to your issue.. but you removed it.

That being said: Your error is simple. That file does not exist.

"/home/foxeson/public_html/site05/" Does WordPress exist in this directory? If you're trying to include your theme, well, it's not going to work it's magic on your own. Add theme elements. Test it out.

You can test out a quick loop that's in the URL I linked you earlier. It won't show a theme and/or WordPress elements if you tell it nothing. That just includes the file to make the magic happen.

Link to comment
Share on other sites

  • 0

Please try not to edit your posts; I get a subscription and I want to reply to your issue.. but you removed it.

That being said: Your error is simple. That file does not exist.

"/home/foxeson/public_html/site05/" Does WordPress exist in this directory? If you're trying to include your theme, well, it's not going to work it's magic on your own. Add theme elements. Test it out.

You can test out a quick loop that's in the URL I linked you earlier. It won't show a theme and/or WordPress elements if you tell it nothing. That just includes the file to make the magic happen.

Yes wordpress exists in that directory.

I edited my post as I hadn't done it correctly, thats why I was getting the error. Once I corrected it, my page was displaying but as it was previously. on a blank background not wrapped in my wordpress site.

Link to comment
Share on other sites

  • 0

I think I've figured it out, I didn't realise I had to add <?php get_header(); ?> after the first bit of code.

Is it possible for it to work if I move my php database files into a seperate directory to wordpress? For instance, site05 = wordpress.

/public_html/site05/database/index.php

I tried changing the php require to the below but it returned an error.

<?php

require('./site05/wp-blog-header.php');

?>

Link to comment
Share on other sites

  • 0

You have to essentially crate the page yourself.

wp-blog-header.php is placed at the TOP of your files ONCE which will then 'allow' you to use WordPress functions. You have to essentially recreate a theme in the sense that you need to pull in various template tags to get it integrated properly.

http://codex.wordpress.org/Template_Tags

You can reference that for stuff you can use.

Link to comment
Share on other sites

  • 0

You have to essentially crate the page yourself.

wp-blog-header.php is placed at the TOP of your files ONCE which will then 'allow' you to use WordPress functions. You have to essentially recreate a theme in the sense that you need to pull in various template tags to get it integrated properly.

http://codex.wordpress.org/Template_Tags

You can reference that for stuff you can use.

Thanks,

See my previous post, is it possible for it to work if my php files are in a different directory?

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.