Skip to content
Advertisement

clicking on a post link leads to a blank page in php wordpress

I have been trying to learn PHP, and I am stuck at one point. I created some posts and made them as links, but on clicking them, they lead me to a blank page.

Here is the index.php code

      <?php 
     while(have_posts()){
        the_post();?>
        <h2><a href="get_the_permalink()"><?php the_title(); ?></a></h2>
        <?php the_content(); ?>
    <?php
     }
    ?>

Here is the single.php code

    <?php 
     while(have_posts()){
        the_post();?>
        <h2><?php the_title(); ?></h2>
        <?php the_content(); ?>
    <?php
     }
    ?>

I changed the href value to another working link, and it was working pretty well, the problem maybe with permalink. I went to WordPress dashboard->permalink and tried all kinds of common settings, but the problem still exists, could someone help me out?

Advertisement

Answer

You have to use PHP functions always wrapped inside <?php?>

<?php 
 while(have_posts()){
    the_post();?>
    <h2><a href="<?php get_the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_content(); ?>
<?php
 }
?>
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement