BlackvsEvgen
Постоялец
- Регистрация
- 13 Янв 2009
- Сообщения
- 103
- Реакции
- 3
- Автор темы
- #1
Добрый день, подскажите как сделать вот так на WordPress:
Спасибо.
Спасибо.
Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
// Получение первой картинки с поста
function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
// Если изображение отсутствует, то выводим изображение по умолчанию (указать путь к изображению)
if(empty($first_img)){
$first_img = "/images/default.jpg";
}
return $first_img;
}
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<img src="<?php echo catch_that_image() ?>" alt="<?php the_title(); ?>"/>
</a>
