Заголовок не работает как ссылка

21 янв. 2013 г., 00:47:03
Просмотры: 74
Голосов: 0

Я знаю, что нет тега ссылки вокруг заголовка, но я не знаю, куда его вставить, помогите пожалуйста :) Вот код:

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'>
                <a href="<?php the_permalink(); ?>"> <?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;
                    }
                    ?>
                </a>
            </h3><!-- .slide_title -->

            <div class='slide_stats'>
                <?php $more_comments = get_comments_number() . '  Комментариев'; ?>
                <?php comments_number( "0 Комментариев", "1 Комментарий", $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">Назад</button>
        <button class="slide_next">Вперед</button>
<?php
endif;
?>
</div><!-- .slides -->
0
Все ответы на вопрос 1
0

Вам нужно разместить это внутри тегов <h3>:

<h3 class='slide_title'>
    <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
        <?php
            // Получаем полный заголовок
            $long_title = get_the_title();
            // Обрезаем заголовок до 55 символов
            $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 -->

Я также немного улучшил ваш код для заголовка :)

21 янв. 2013 г. 01:11:19