Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I have a button for each of the events I want and I want the user when they click it to be taken to the post, but when clicked they do not get taken to the post, rather they get taken to the front page which is not I want. The button was created in CSS, not WordPress here is my code.
    "<div class="col-md-4">
<?php $post_id = 5451;
$queried_post = get_post($post_id);?>
<h3><?php echo $queried_post->post_title; ?></h3>
  <p><?php echo get_the_date( 'j F, Y' ); ?></p>
<?php echo $queried_post->post_excerpt; ?>
<?php echo get_the_post_thumbnail($queried_post, 'full', array('class' => 'img-responsive')); ?>
<?php echo '<a class="btn2 readmore" href="'.get_permalink($queried_post).'">Find Out More</a>';?> "




(this code above is in my index.php)
"<div class="col-md-4">
             <h3>Spacey Jane: MUSIC</h3>
        <p id="spaceyjane">Following huge demand for their first show, Spacey Jane announced a second date on their forthcoming national Sunlight tour. They're joined by special guests Jack Davies and the Bush Chooks.</p>
        <p id="date1">Sat 10 Apr  2021  |  6:00pm — 10:00pm | South Lawn</p>
            <img src="images/event1.png" alt="spaceyjane">
              <button type="button" class="btn2">Find Out More</button>
         </div>`  <div class="col-md-4">
             <h3>Spacey Jane: MUSIC</h3>
        <p id="spaceyjane">Following huge demand for their first show, Spacey Jane announced a second date on their forthcoming national Sunlight tour. They're joined by special guests Jack Davies and the Bush Chooks.</p>
        <p id="date1">Sat 10 Apr  2021  |  6:00pm — 10:00pm | South Lawn</p>
            <img src="images/event1.png" alt="spaceyjane">
              <button type="button" class="btn2">Find Out More</button>
         </div>"


(this code above is in my index.html)[front page events section][1]


[1]: https://i.stack.imgur.com/Q6wOu.png

What I have tried:

I have tried moving the post id and get post above col-md-4, that did not do anything.
Posted
Updated 2-Jun-21 13:06pm
v2
Comments
Richard Deeming 3-Jun-21 4:02am    
There's something wrong with your get_permalink function, which you haven't shown. Either it's not generating the correct URL, or the URL it's generating doesn't route to the correct page.

Nobody can help you based on the information you have provided so far.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900