• Resolved nathanwinkelmes

    (@nathanwinkelmes)


    Ok I am having an issue with a WordPress site. I am trying to show the posts as excerpts, which is working. But, I want the title to be a link just like the read more text. I have successfully changed the title to a link, but when clicked, it just adds the_permalink(); to the end of the url and I get the 404 page. Here is a snippet of the code from the loop. This is where the issue lies. This code resides in archive.php in the twentyfourteen theme. Hoping someone can help! Thanks!

    // Start the Loop.
    while ( have_posts() ) : the_post();
    
    // Displays posts as excerpts
    
    the_title('<a href="the_permalink();"><h2 style="text-transform:uppercase;">','</h2></a>');
    the_excerpt();
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    PHP cannot parse code within a string argument. You have to concatenate the parts like so:
    '<a href="' . get_the_permalink() . '"><h2 style="text-transform:uppercase;">'

    We use the “get” variant here because it returns a value for PHP to use instead of echoing it out to the browser.

    Thread Starter nathanwinkelmes

    (@nathanwinkelmes)

    You are my hero! Looking back I’m kicking myself because I was thinking way too much. Thanks so much for your fix, it worked!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WP Excerpt title link issue’ is closed to new replies.