WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following coding:

        global $post;
        $args = array( 'numberposts' => 8);
        $myposts = get_posts( $args );
        foreach( $myposts as $post ) :  setup_postdata($post);
        echo '<a href='.the_permalink().'>'.the_title().'</a><br />';

Dreamweaver is highlighting a potential syntax error on line 6 & 7. I'm sure it's something very very simple but can someone point me in the right direction to solve this error please?

share|improve this question
Seems okey to me. Did you tried running it? Sometimes Dreamweaver shows error where isn't any. Happened to me couple of times. – Sisir Mar 5 '12 at 12:44
+1 @Sisir - happens to me a lot; might be the quotes missing around the link url. – Michael Mar 5 '12 at 13:20
I just put this into Dreamweaver CS5.5 (directly copy-pasted) and I'm not getting an error. – mor7ifer Mar 5 '12 at 13:49
up vote 3 down vote accepted

Not sure if it is causing Dreamweaver to flag an error (try running it?), but on the second from last line you want to be using get_the_title(). This returns the posts' title, whereas the_title() will echo it.

echo '<a href='.the_permalink().'>'.get_the_title().'</a><br />';
share|improve this answer
same with: the_permalink() -> get_permalink($post->ID) – Michael Mar 5 '12 at 13:21
Yup, I missed that one. – Stephen Harris Mar 5 '12 at 13:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.