• I’m fairly new to theme programming but I think this will be a pretty easy answer for the community.

    On my Home page, I am customizing excerpt content. I want to customize the Read More link below some other customized excerpt content.

    How do I call out the post URL in a PHP echo statement? I tried this:

    <?php
    <a href="'. get_permalink($post->ID) . '"> Get more info...</a>;
     ?>

    It gave me a nasty error that didn’t show up when I used just a traditional URL in the HREF field…so, I figure there’s something wrong with the callout. Help!

Viewing 1 replies (of 1 total)
  • You have invalid– very invalid– PHP. Your anchor tag is inside a PHP block but isn’t a proper string so PHP is going to try to execute it as if it were PHP code, and since it isn’t you get a nasty error.

    <?php
    echo '<a href="'.get_permalink($post->ID).'"> Get more info...</a>';
    ?>

    Notice the single quote marks at the beginning and end of the string, and the ‘echo’ statement.

    You could also do:

    <a href="<?php echo get_permalink($post->ID); ?>">Get more info...</a>

    Assuming I didn’t make a mistake, those should work.

Viewing 1 replies (of 1 total)
  • The topic ‘New to theme programming: PHP home page link to single post’ is closed to new replies.