• In my recent posts list, all the links except the first one aren’t working. The html output all looks fine, but when you hover over the link Instead of showing something like http://www.mysite.com/?p=40 it shows http://www.mysite.com/<?php echo get_permalink(); ?> which is obviously the code I’ve put in and gives a 404 error if you actually click on it. I’ve tried changing it to <?php the_permalink(); ?> and a bunch of similar things but again it’s not getting the link, its just displaying the code I change it to. I can’t figure out what I’m doing wrong!

    Here is the code snippet within the loop that’s got the dodgy links:

    <?php $query2 = new WP_Query('posts_per_page=5&offset=1');
      while( $query2->have_posts() ):
    	$query2->next_post();
    		echo '<li><a href="<?php echo get_permalink(); ?>"><h2>' . get_the_title( $query2->post->ID ) . '</h2></a></li>';
    endwhile;
    ?>

    And here is the website:

  • The topic ‘Links not working in my recent posts’ is closed to new replies.