Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Putting normal php into Wordpress - PHP Experts available?

Featured Replies

WDF'ers!

 

Someone mind helping me with this problem, I basically have an external script that I want to use with WP and I wan't it to work well!

 

Basically below is the code that I am using for WP and holds all the information that I need for my database search and display to work, it stops at <div> content. When the require_once is activated, and then nothing else get's displayed. Why's that?

 

I have it working here:

 

http://universitycom...nder/finder.php

 

and I also have the code that this page: http://universitycompare.com/courses/ is suppose to display (see below)..

 

 

 

<?php
/*
Template Name: Courses
*/
?>

<?php get_header(); ?>

<div class="content" style="border-right:1px solid #afd1e2;">

<?php
require_once('/var/www/vhosts/universitycompare.com/httpdocs/wp-content/themes/blue-and-grey/CourseFinder/config.php');
require_once('/var/www/vhosts/universitycompare.com/httpdocs/wp-content/themes/blue-and-grey/CourseFinder/functions.php');
?>
Find a course:
<!-- The search form submitted via AJAX -->
<div id="search-widget">
<h3>Course Search</h3>
<form method="get" name="course-serach" action="">
<input type="hidden" name="page_number" value="1" id="page_number"/>
<input type="hidden" name="min_fee" value="0" id="min_fee"/>
<input type="hidden" name="max_fee" value="0" id="max_fee"/>
<table>
<tr>
<td colspan="2">
<input type="text" name="course_name" id="course_name" placeholder="Please enter a course name"/>
</td>
<td>
<select name="course_type" id="course_type">
<option value="1">Full time</option>
<option value="2">Part time</option>
</select>
</td>
</tr>
<tr>
<td>Tuition Fee </td>
<td>
<div id="course_fee" style="width:300px;"><br/>
<div id="fee_range"></div>
</div>
</td>
<td>
<select name="university" id="university" disabled ="true">
<?php echo "<option>University of Londons</option>" ?>
</select>
</td>
</tr>
</table>
</form>
</div>

<select name="order_by" id="order_by">
<option value="fee asc">Tuition ascending</option>
<option value="fee desc">Tuition descending</option>
<option value="course_name asc">Course Title ascending</option>
<option value="course_name desc">Course Title descending</option>
</select>
<div id="results" style="margin-top: 15px;">
</div>

<!-- Having some style issues, so placed it here -->
<div id="row-header" style="margin-bottom: 15px;">
Search results <span id="result-count"></span>
</div>
<div id="pagination">
</div>



<?php get_footer(); ?>

 

Any help is good help!

Edited by OwenONeill

That normally means there's a PHP error. If it's a dev site or on localhost, use:

 

define('WP_DEBUG', true);

 

in wp-config.php to display errors.

 

If it's a live site, use:

 

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

 

and check debug.log in /wp-content/

  • Author

there is no debug.log found in /wp-content after adding the information my live site.

 

Any more ideas? - just want something to go on..

You may need to create it first - create a blank file called debug.log, upload to wp-content and chmod 666.

 

Edit: at a rough guess, something about your includes is going wonky. Does the same thing happen if you change require_once to include_once?

Edited by Renaissance-Design

  • Author

Edit: at a rough guess, something about your includes is going wonky. Does the same thing happen if you change require_once to include_once?

 

Right, getting somewhere! include_once actually sorts out the page. so it is the require_once that is generating the problem - do you know how to fix it by any chance?

The difference between include_once and require_once is require will throw an error if it fails to include the file, so evidently your paths are wrong.

  • Author

The difference between include_once and require_once is require will throw an error if it fails to include the file, so evidently your paths are wrong.

 

What sort of path should I be using? Should it be a URL path:

http://universitycompare.com/wp-content/themes/blue-and-grey/CourseFinder/config.php

 

or this sort of path:

/var/www/httpdocs/wp-content/themes/blue-and-grey/CourseFinder/config.php

 

- just new to the whole thing..

  • Author

Filesystem path. Try relative to the file you're including from.

 

Right well I have just put it all very local so it works - when the filepaths are correct it doesn't display anything after the PHP - when they are not correct, it loads everything.. Any help there?

If the paths are definitely correct, the problem must be somewhere in one of the files. Try including one but not the other to narrow down each one, then comment out sections until you arrive at the bit that's causing the problem.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.