Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Syntax and/or output behaviour

Syntax and/or output behaviour

Syntax and/or output behaviour

As of about 30 minutes ago, decided to look at WordPress ... they say it is never too late.

Can you please tell me why this snippet does not work?


if(have_posts()) :
    while(have_posts()) : the_post();
        echo '<h2><a href="'.$link.'">'.$title.'</a></h2>';
else :
    echo '<p>No content found!</p>';

I do not want to fight the system - if WordPress needs me to open and close PHP each time I need to inject something, I guess that is what I'll do. I just want to understand if this is a "rule" and/or if I am missing something with a rather not too sophisticated routine.

The good thing about not knowing is the opportunity to learn - Yours truly, 2008.

RE: Syntax and/or output behaviour

This is the post display loop, called the_loop in WordPress parlance.

It creates a link from the current post (the_post) URL (the_permalink) using the post title (the_title) that is formatted and displayed as a heading level 2, then displays the post data (the_content)

Complete WP function reference.


Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

RE: Syntax and/or output behaviour


Can you please tell me why this snippet does not work?
Define "does not work".

Where did this snippet come from, what did you want it to do, and what did it actually do?

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close