0

When I click on a link to redirect to 'single_assignment_page.php' it is not showing the content of this page but it is showing the content of 'index.php'. That's something I don't want but in the URL bar it is showing the right URL that I want. I'm working with my own theme in WordPress.

front-page.php with the link at the bottom

<div class="container">
<h2 class="title-section" >Opdrachten</h2>
<p>Hieronder staan de opdrachten vermeld die zijn ingezonden door bedrijven en particulieren. Het is gesorteerd van nieuw naar oud. De opdrachten zijn alleen te zien voor ingelogde gebruikers.</p>

<?php
$results = $wpdb->get_results( "SELECT id, voornaam, achternaam, bedrijfsnaam, telefoonnummer, emailadres, titel_opdracht, opdrachtbeschrijving FROM form_entry"); // Query to fetch data from database table and storing in $results
if(!empty($results))                        // Checking if $results have some values or not
{
    echo "<table width='100%' border='0'>"; // Adding <table> and <tbody> tag outside foreach loop so that it wont create again and again
    echo "<tbody>";
    foreach($results as $row){
        echo "<tr>";                           // Adding rows of table inside foreach loop
        echo "<th>ID</th>" . "<td>" . $row->id . "</td>";
        echo "</tr>";
        echo "<td colspan='2'><hr size='1'></td>";
        echo "<tr>";
        echo "<th>Voornaam</th>" . "<td>" . $row->voornaam . "</td>";   //fetching data from user_ip field
        echo "</tr>";
        echo "<td colspan='2'><hr size='1'></td>";
        echo "<tr>";
        echo "<th>Achternaam</th>" . "<td>" . $row->achternaam . "</td>";
        echo "</tr>";
        echo "<td colspan='2'><hr size='1'></td>";
        echo "<tr>";
        echo "<th>Bedrijfsnaam</th>" . "<td>" . $row->bedrijfsnaam . "</td>";
        echo "</tr>";
        echo "<td colspan='2'><hr size='1'></td>";
        echo "<tr>";
        echo "<th>Telefoonnummer</th>" . "<td>" . $row->telefoonnummer . "</td>";
        echo "</tr>";
        echo "<td colspan='2'><hr size='1'></td>";
        echo "<tr>";
        echo "<th>E-mailadres</th>" . "<td>" . $row->emailadres . "</td>";
        echo "</tr>";
        echo "<td colspan='2'><hr size='1'></td>";
        echo "<tr>";
        echo "<th>Titel opdracht</th>" . "<td>" . $row->titel_opdracht . "</td>";
        echo "</tr>";
        echo "<td colspan='2'><hr size='1'></td>";
        echo "<tr>";
        echo "<th>Opdrachtbeschrijving</th>" . "<td>" . $row->opdrachtbeschrijving . "</td>";
        echo "</tr>";
        echo "<td colspan='2'><hr size='1'></td>";
        echo "<tr>";
        echo '<td><a href="single_assignment_page.php?id='.$row->id.'">Hello</td>';
        echo "</tr>";
    }
    echo "</tbody>";
    echo "</table>";

}
?>

single_assignment_page.php

<?php $assignment_id = $_GET['id']; ?>

<?php get_header(); ?>

<?php the_content(); ?>
<p>Hey</p>
<p>Hey</p>
<p>Hey</p>
<p>Hey</p>
<p>Hey</p>
<p>Hey</p>
<p>Hey</p>
<?php get_footer(); ?>

I already tried some things:

  • Tried to redirect without the id at the end of the url, then he still shows the index.php content.
  • Tried to redirect to a other PHP file, but it is still showing the content of index.php.
  • Edit the .htaccess file but I still got the same problem.

I hope someone can help me out, because I've been stuck with this problem for a whole day. Thanks for the effort.

3
  • If I understand it correctly, you should make the single_assignment_page.php as a page template then create a Page (post type of page) and assign the template to that Page. Then instead of linking to single_assignment_page.php, you would link to the Page's permalink.
    – Sally CJ
    Commented Mar 30, 2021 at 22:43
  • 1
    Thank you very much @SallyCJ! That was indeed the solution.
    – Jakub
    Commented Mar 31, 2021 at 9:36
  • I'm glad I could help, but you might want to post an answer and describe the steps you've taken to solve the problem in question. (And accept your answer later on.) 🙂
    – Sally CJ
    Commented Mar 31, 2021 at 13:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.