• I placed this code on my sidebar to show the recent posts.
    The php tags(the_permalink and the_title) appear before everything, not inside the code as i want.

    I’m usind in_category inside get_posts.

    The PHP code

    <?php
    $posts = get_posts('numberposts=10&offset=1');
    foreach($posts as $post) :
    setup_postdata($post);
    ?>
    
    <?php if ( in_category(5) ) {
    echo '<li><a href=/"'.<em>the_permalink()</em>.'/" alt=/"Leia o post/"><b>'.<em>the_title()</em>.'</b></a>';
    } else {
    echo '<span class="bad-cat">This is a BAD category</span>';
    }
    ?>
    
    <?php endforeach; ?>

    The result is like this

    http://localhost/wordpress/?p=31Gamurize<a href=/"/" alt=/"Leia o post/"><b></b></a>

    And should be like this

    <a href="http://localhost/wordpress/?p=31" alt=/"Leia o post/"><b>Gamurize</b></a>

    Why is this happening???

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Php echoes before everything’ is closed to new replies.