Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I know there is no link tag around title, but I don't know where to put it, please help me :) This is code

if ($columns->have_posts()) :
    $count = 0;
        while ($columns->have_posts()) : $columns->the_post();
        $count++;
?>
        <div class="slide">
            <div class="slides_thumbnail">
                <a href="<?php the_permalink(); ?>">
                    <div style="width:190px;height:190px;background:url('<?php 
                     $img = get_the_post_thumbnail();
                    eregi("src=\"([^\"]+)\"", $img, $arr);

                    echo $arr[1]; ?>');">&nbsp;</div>

                    <span class="image overlay"></span>
                    <span class="description"></span>
                </a>
            </div><!-- .slides_thumbnail -->
            <h3 class='slide_title'>
                <?php

                    $long_title = strip_tags(htmlspecialchars(get_the_title($post->ID)));
                    $short_title = substr($long_title,0,55);

                    if (strlen($long_title) !== strlen($short_title)) {
                        echo $short_title . "... ";
                    } else {
                        echo $short_title;
                    }
                    ?>
            </h3><!-- .slide_title -->

            <div class='slide_stats'>
                <?php $more_comments = get_comments_number() . '  Komentar(a)'; ?>
                <?php comments_number( "0 Komentar(a)", "1  Komentar(a)", $more_comments ); ?> 
            </div><!-- .slide_stats -->

            <div class="slides_text">
                <p>
                    <?php 
                    if(function_exists('the_excerpt_max_charlength')) {
                            the_excerpt_max_charlength(300); 
                        } else {
                            the_excerpt(); 
                        }
                    ?>
                </p>
            </div><!-- .slides_text -->
        </div><!-- .slide -->
<?php
    endwhile;
endif;
?>
    </div><!-- .slides_container -->
<?php
if($count > 1) :
?>
        <button class="slide_prev">Previous</button>
        <button class="slide_next">Next</button>
<?php
endif;
?>
</div><!-- .slides -->
share|improve this question
add comment

1 Answer

You need to put it inside the <h3> tags:

<h3 class='slide_title'>
    <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
        <?php
            $long_title = get_the_title();
            $short_title = substr( $long_title, 0, 55 );

            if ( strlen( $long_title ) !== strlen( $short_title ))  {
                echo $short_title . '&hellip;';
            } else {
                echo $short_title;
            }
        ?>
    </a>
</h3><!-- .slide_title -->

I've also fixed up your title code for you a bit :)

share|improve this answer
add comment

Your Answer

 
discard

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.