get_header wp函数在特定页面上不起作用

时间:2019-04-11 14:06:57

标签: wordpress

get_header()wp函数在我需要的页面上不起作用。它可以在其他页面上使用。我得到的错误是:

Fatal error: Uncaught Error: Call to undefined function get_header() in /home/vhosts/tweb.nl/httpdocs/wp-content/themes/tweb/oplselect.php:5 Stack trace: #0 {main} thrown in /home/vhosts/tweb.nl/httpdocs/wp-content/themes/tweb/oplselect.php on line 5.

该错误仅显示在此页面上,而不显示在其他使用get_header()的页面上; 页面设置非常正常,并且像其他页面一样构建

page-oplselect.php:

get_header();
include '/home/vhosts/tweb.nl/httpdocs/wp-content/themes/tweb/db/dbcon.php';


 $oplid = $_POST['selected'];


$query = $conn->prepare('SELECT C.CursusPsID, O.Opleidingnaam, DATE(CO.Datum) AS DatumVanaf, C.Plaatsen, CC.Aantal, (C.Plaatsen - CC.Aantal) AS Beschikbaar,
CASE WHEN COL.pslocatieid > 0 THEN L.locatienaam WHEN COL.BedrijfID > 0 THEN B.bedrijfnaam ELSE "Geen locatie" END AS Locatie
FROM Cursussen C
LEFT JOIN Opleidingen O ON C.OpleidingID = O.OpleidingID
LEFT JOIN CursusOnderdeelLocaties COL ON C.CursusPsID = COL.CursusPsID
LEFT JOIN Bedrijven B ON COL.BedrijfID = B.BedrijfID
LEFT JOIN Locaties L ON COL.PsLocatieID = L.PsLocatieID
LEFT JOIN (SELECT CursusPsID, COUNT(CursistPsID) AS Aantal FROM CursusCursisten GROUP BY CursusPsID) CC ON C.CursusPsID = CC.CursusPsID
LEFT OUTER JOIN (SELECT CursusPsID, MIN( Tot ) AS Datum FROM CursusOnderdelen
GROUP BY CursusPsID) CO ON C.CursusPsID = CO.CursusPsID
WHERE C.OpleidingID = :OpleidingID
GROUP BY CursusPsID');
$query->bindParam(':OpleidingID', $oplid, PDO::PARAM_INT);
$query->execute();

echo "<table class='table'>
<tr>
<th>Datum</th>
<th>Cursus</th>
<th>Locatie</th>
<th>Beschikbare plaatsen</th>
<th>inschrijven</th>
</tr>";


while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    echo "<tr>";
        echo "<td>". $row["DatumVanaf"] . "</td>";
        echo "<td>" . $row["Opleidingnaam"] . "</td>";
        echo "<td>" . $row["Locatie"] . "</td>";
        echo "<td>" . $row["Beschikbaar"] . "</td>";
        echo "<td><button id='selecteren' class='selecteren' value=" .$row["CursusPsID"] .">Inschrijven</button</td>";
        echo "</tr>";
        }
        echo "</table>";


 ?>

<script>
    $(document).ready(function(){
        $("#selecteren").click(function(){
        var cursus =  $('#selecteren').val($(this).text());
                    $.ajax({
                    type: "POST",
                    url: "/wp-content/themes/tweb/cursusdetails.php",
                    data: {'cursus':cursus},
                    success: function(data){
                        $('#cursusdetails').html(data);
                        console.log(data);
                    },
                    error: function(e){
                        console.log(e.message);
                    }
                });
            });
        });
 </script>

1 个答案:

答案 0 :(得分:1)

如果(!defined('ABSPATH'))退出;

将此代码放在页面顶部,然后重试。