Я очень новичок в PHP и действительно не знаю, с чего начать, когда дело доходит до его написания.
Я нашел эту функцию для Wordpress, которую я использую:
function excerpt($limit) {
$excerpt = explode(' ', get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(" ",$excerpt).'<a href="<?php the_permalink(); ?>">Read In Full</a>';
} else {
$excerpt = implode(" ",$excerpt);
}
$excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
return $excerpt;
}
function content($limit) {
$content = explode(' ', get_the_content(), $limit);
if (count($content)>=$limit) {
array_pop($content);
$content = implode(" ",$content).'[...]';
} else {
$content = implode(" ",$content);
}
$content = preg_replace('/\[.+\]/','', $content);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
return $content;
}
В приведенном выше коде я разместил
"<?php the_permalink(); ?>"
в хреф. Он просто отображается как строка слов вместо создания вызова ссылки на сообщения.
Кто-нибудь мне поможет?? Спасибо!
<?php $firmnews = new WP_Query(); $firmnews->query('showposts=2'); while ($firmnews->have_posts()) : $firmnews->the_post(); ?> <div class="firmnews_content"> <p> <span class="yellow"><?php Echo get_the_date(); ?></span> <?php echo excerpt(20); ?> </p> </div> <?php endwhile; ?>
Функция создает ссылку «Читать полностью» на отрывке. - person Devon   schedule 12.10.2011the_permalink()
наget_permalink()
. the_permalink() отображает ссылки, а get_permalink() возвращает их. В вашем случае вы добавляете ссылку, поэтому предпочтительнее вторая - person sbrajesh   schedule 12.10.2011