treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Permalinks not working on latest blog post.

  • So I have a normal loop that you can see here:

    <?php if ( have_posts() ): ?>
      <?php while ( have_posts() ) : the_post(); ?>
        <article>
          <div class="featured-image"><?php the_post_thumbnail(); ?></div>
            <div class="blog-date">
              <div class="date"><?php the_time('M, j') ?></div>
              <p class="tahoma-low"><?php comments_number('0', '1', '%'); ?></p>
            </div>
            <div class="post-info">
                    <h2><a href="<?php esc_url( the_permalink() ); ?>" title="Permalink to <?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
            <hr />
            <p class="photo-credit tahoma-low">photo courtesy whomever 2012</p>
            <p class="excerpt"><?php the_excerpt(); ?></p>
            <a href="<?php esc_url( the_permalink() ); ?>" ><img src="<?php echo get_bloginfo('template_directory');?>/images/contactMeTape.png"></a>
          </div><!--POST INFO END-->
        </article>
      <?php endwhile; ?>
    
    <?php else: ?>
      <h2>No posts to display</h2>
    <?php endif; ?>
    

    What happens is the latest blog posts title and read more button do not work. I figured it is just the permalinks but I have NO IDEA what it could be. I tried tones of google searches but with no luck. Any help would be amazing. I cannot upload this because it is being developed locally so sorry about that.

    EDIT: Also When there is only one blog post the permalinks work fine. Another big thing is that when I inspect the element that should have the link, it shows it has a link but you cannot click it.

  • That esc_url function is one I haven't seen before. Does it work if you remove it? Or use esc_attr instead?

  • I tried that and the normal <?php the_permalink(); ?> and still nothing. I still have no clue and I am still going threw forums and posts with no luck.

  • Here is a link to a screenshot of the inspect. As you can see it shows the link there:

    https://www.dropbox.com/s/5eyklni14m1ijps/WTFwordpress.png

  • Perhaps it's something in your JavaScript. Try turning JS off and see if the links work.

  • Just disabled Javascript and still not working :(

  • Does anybody know why links would not be clickable even though they show up in the source code as a link?

  • Try typing in the URL manually (or copy/paste from the Inspector) and make sure that works. It might just lead to the same page, which WordPress sometimes create if the link doesn't exist.

  • Do you not have a link to send us to?

    Are you being taken to a 404 page? If so, go to Settings > Permalinks and just hit save again. Sounds like it could be something wrong with your htaccess.

    If you can't even click it, then it sounds like something is either covering the button or you've got some sort of e.PreventDefault(); or return false going on in your JS.

  • @TheDoc we've already established that it isn't a JS problem - it still didn't work with JS off.

  • try changing the permalink structure and see what happens. Or just go back in and re save whatever option you have set

  • kmullins,

    Check your divs and CSS to make sure nothing is overlapping the link. You can do these easily with inspecting elements. Right-click the TITLE TWO and inspect element and see what pops up.