Skip to content
Advertisement

WordPress how to get a single post link

I want to go to single.php file when this button is clicked.

<div class="recepies-search">
        
        <div class="card m-1" style="width: 18rem;">
  <img class="card-img-top" src="<?get_the_post_thumbnail()?>" >
  <div class="card-body">
    <h5 class="card-title"><?php the_title();?></h5>
   <button type="button" class="btn btn-warning" onclick="<?php get_permalink()?>">click</button>

  </div>
</div>
    </div>

but it doesn’t do anything.

Advertisement

Answer

Replace this:

<button type="button" class="btn btn-warning" onclick="<?php get_permalink()?>">click</button>

with this:

<a href="<?php the_permalink() ?>">click</a>

And then style your a tag like a button.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement