how to put in if clause ? (2 posts)

  1. huynguoidacbiet
    Posted 2 years ago #

    i use this code to echo thumbnail for first post in loop.

    [ Moderator Note: Code backticks fixed. ]

    <?php $count = 0; $loop_baihoccuocsong1 = new WP_Query('cat=3&showposts=1'); // Them category 2
    while($loop_baihoccuocsong1->have_posts()) : $loop_baihoccuocsong1->the_post(); ?>
        <a>" rel="bookmark" title="<?php the_title_attribute(); ?>">
                    echo '<img src="<?php echo get_post_meta($post->ID, "thumbnail", true);?>;$counter++;"/>' ;
        <div class="h_bai-hoc-cuoc-song-1">
            <a>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
            <?php the_content(); ?>
    <?php endwhile; ?>
    <?php wp_reset_postdata(); // Reset the query ?>

    There are any error in if clause.
    Browser cannot echo url thumbnail.
    Please help me fix it.
    Thank you !

  2. ianhaycox
    Posted 2 years ago #

    $count and $counter

    Follow http://codex.wordpress.org/Debugging_in_WordPress and the uninitiialised $counter variable would have been reported.

    Also - the <a> tags are closed too early for the rel attribute etc.

    <a rel="bookmark" title="<?php the_title_attribute(); ?>">

Topic Closed

This topic has been closed to new replies.

About this Topic