Перевести код php в functions
-
Всем доброго времени суток!
Чтобы Google News корректно считывали миниатюру в посте, а не брали первую картинку в статье, мне приходится использовать функцию вставки кода в начало записи.
Я использую такой код:add_filter( 'the_content', 'featured_image_before_content' ); function featured_image_before_content( $content ) { if ( is_singular('post') && has_post_thumbnail()) { $thumbnail = get_the_post_thumbnail(); $content = $thumbnail . $content; } return $content; }
Он превосходного выполняет свою функцию, но отображение выглядит не так, как мне нужно. Мне необходимо как-то перевести код ниже в функцию выше. Прошу помощи.
<div class="widget-week-item5"><?php if ( has_post_thumbnail()): ?><?php the_post_thumbnail(); ?><?php endif;?> <div class="widget-week-content5"> <div class="item-comments5"> <span class="categorys5"><?php the_category(', '); ?></span> <span class="item-views5"><i class="fa fa-clock-o"></i> <?php the_time( get_option( 'date_format' ) ); ?> | <i class="fa fa-comment-o"></i> <span class="count-comment{num}"><?php comments_number('0', '1', '%');?></span> </a> | <i class="fa fa-eye"></i> <?php if(function_exists('the_views')) { the_views(); } ?></span></div> <a class="title" ><?php the_title(); ?></div></div> </a>
- Тема «Перевести код php в functions» закрыта для новых ответов.