Поставил AMP плагин. Но возникла проблема. На вордпресс тег <!--noteaser--> по умолчанию выводит то, что идет до него в качестве уникального анонса. Плагни же AMP не понимает этого тега. В итоге хочу подпилить функцию вывода его собственную, чтобы она была похожа на стандартную get_the_content().И так вот сама функция get_the_content():
А вот, как я понял, примитивный ее аналог в плагине:
В итоге мне сюда надо добавить либо часть со стандартной ф-ии, которая удаляет до тега <!--noteaser--> вывод. Либо можно просто $strip_teaser = false, и тогда будет удалятся все до тега <!--more-->. Меня бы устроил любой вариант.
Просто хоть теоретически подскажите, в какую сторону копать? А то я методом тыка много, что пробовал.
Или пишите в ЛС цену, без проблем договоримся.
Код |
---|
function get_the_content( $more_link_text = null, $strip_teaser = false ) { global $page, $more, $preview, $pages, $multipage; $post = get_post(); if ( null === $more_link_text ) { $more_link_text = sprintf( '<span aria-label="%1$s">%2$s</span>', sprintf( /* translators: %s: Name of current post */ __( 'Continue reading %s' ), the_title_attribute( array( 'echo' => false ) ) ), __( '(more…)' ) ); } $output = ''; $has_teaser = false; // If post password required and it doesn't match the cookie. if ( post_password_required( $post ) ) return get_the_password_form( $post ); if ( $page > count( $pages ) ) // if the requested page doesn't exist $page = count( $pages ); // give them the highest numbered page that DOES exist $content = $pages[$page - 1]; if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) { $content = explode( $matches[0], $content, 2 ); if ( ! empty( $matches[1] ) && ! empty( $more_link_text ) ) $more_link_text = strip_tags( wp_kses_no_null( trim( $matches[1] ) ) ); $has_teaser = true; } else { $content = array( $content ); } if ( false !== strpos( $post->post_content, '<!--noteaser-->' ) && ( ! $multipage || $page == 1 ) ) $strip_teaser = true; $teaser = $content[0]; if ( $more && $strip_teaser && $has_teaser ) $teaser = ''; $output .= $teaser; if ( count( $content ) > 1 ) { if ( $more ) { $output .= '<span id="more-' . $post->ID . '"></span>' . $content[1]; } else { if ( ! empty( $more_link_text ) ) /** * Filters the Read More link text. * * @since 2.8.0 * * @param string $more_link_element Read More link element. * @param string $more_link_text Read More text. */ $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-{$post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text ); $output = force_balance_tags( $output ); } } if ( $preview ) // Preview fix for JavaScript bug with foreign languages. $output = preg_replace_callback( '/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output ); return $output; } |
Код |
---|
public function get_amp_content() { return $this->amp_content; } |
В итоге мне сюда надо добавить либо часть со стандартной ф-ии, которая удаляет до тега <!--noteaser--> вывод. Либо можно просто $strip_teaser = false, и тогда будет удалятся все до тега <!--more-->. Меня бы устроил любой вариант.
Просто хоть теоретически подскажите, в какую сторону копать? А то я методом тыка много, что пробовал.
Или пишите в ЛС цену, без проблем договоримся.
Изменено:
Иван - 13 Сентября 2016 01:11