По-умолчанию переменная %%excerpt%% плагина WordPress SEO by Yoast 155 символов. Что затрудняет ее использование в description и социальных мета тегах.
Увеличим на 101 символ
в файле wordpress-seo/inc/class-wpseo-replace-vars.php
ищем кусок
1 2 3 4 5 6 7 8 | if ( ! empty( $this->args->ID ) ) { if ( $this->args->post_excerpt !== '' ) { $replacement = strip_tags( $this->args->post_excerpt ); } elseif ( $this->args->post_content !== '' ) { $replacement = wp_html_excerpt( strip_shortcodes( $this->args->post_content ), 155 ); } } |
меняем значение 155 на 256. Сохраняем. Проверяем.
Готово!
Чтобы meta тег description не заканчивался куском слова, делаем обрезку по количеству слов:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | private function retrieve_excerpt() { $replacement = null; if ( ! empty( $this->args->ID ) ) { if ( $this->args->post_excerpt !== '' ) { $replacement = strip_tags( $this->args->post_excerpt ); } elseif ( $this->args->post_content !== '' ) { $replacement = wp_trim_words( strip_shortcodes( $this->args->post_content ), 32, ' ' ); } } return $replacement; } |
Здравствуйте! а по подробнее объяснить можете?)