Page 1 of 1

HELP - PHP doesnt like me

Posted: Fri Nov 20, 2009 5:57 pm
by bgbs
I need help because php does everything I dont want it to do, and nothing that I want it to do. This supposed to echo recent articles from wordpress on static homepage. It's doing weird things for some reason.
First, it spits out the actual permalink instead of the Title Link
Secondly, after the permalink it spits out the Title but it disregards all the <h1>/<h4> tag styling, and the title is not a link, which it should be.

Wow it actually displays the content correctly. The Title link supposed to render <h1>/<h4> style but it does not, of course.

Please help because I have serious problems with PHP.

Code: Select all

<?php
$recent = new WP_Query("cat=1&showposts=6");
$i = 0;
while($recent->have_posts()) : $recent->the_post();
  if($i == 0){
    echo '<h1><a href="';
    the_permalink();
    echo '" rel="bookmark">'.the_title().'</a></h1>';
    if (function_exists('the_content_limit')){
          the_content_limit(195, "<span class='read-more'>Read more &raquo;</span>");
    }
  }else{
    echo '<h4><a href="';
    the_permalink();
    echo '" rel="bookmark">'.the_title().'</a></h4>';
    the_content_limit(130, "");
    echo '<div class="hppostmeta">';
    echo '<p>'.the_time('F j, Y').' | <a href="';
    the_permalink();
    echo '" rel="bookmark">Read the story &raquo;</a></p>';
    echo '</div>';
  }
echo '<div style="clear:both;"></div>';
$i++;
endwhile; ?>

Re: HELP - PHP doesnt like me

Posted: Sat Nov 21, 2009 2:25 am
by cpetercarter
The problem isn't with php. It is that you are not sufficiently familiar with Wordpress.

When you hit a problem that the page does not display what you want it to display, one of the first things to do is to look at the page source (ie the html) of the output page. That will generally show you where there is an error in your syntax, or the fact that a function like the_permalink() does not output what you think it does.

If you care to post the page source here, I am sure that forum members will try to help.