` tag. * @global int $multipage Boolean indicador для будь-яких multipages є в play. * * @param string $more_link_text Optional. Content for when there is more text. * @param bool $strip_teaser Optional. Strip teaser content before the more text. Default false. * @param WP_Post|object|int $post Optional. WP_Post instance or Post ID/object. Default null. * @return string */” data-tooltip_type=”pre”>Код get_the_content() get the content WP 6.0.2
function get_the_content( $more_link_text = null, $strip_teaser = false, $post = null ) { Global $page, $more, $preview, $pages, $multipage; $_post = get_post($post); if ( ! ( $_post instanceof WP_Post ) ) { return ''; } // Use the globals if the $post parameter був не specified, // Але тільки після того, як вони повинні бути налаштовані в setup_postdata(). if ( null === $post && did_action( 'the_post' ) ) { $elements = compact( 'page', 'more', 'preview', 'pages', 'multipage' ); } else { $ elements = generate_postdata( $_post ); } if ( null === $more_link_text ) { $more_link_text = sprintf( '<span aria-label="%1$s">%2$s</span>', sprintf( /* translators: %s: Post title. */ __( 'Continue reading %s' ), the_title_attribute( array( 'echo' => false, 'post' => $_post, ) ) ), __( '(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 the requested page doesn't exist. if ( $elements['page'] > count( $elements['pages'] ) ) { // Give them the highest numbered page that DOES exist. $elements['page'] = count( $elements['pages'] ); } $page_no = $elements['page']; $content = $elements['pages'][ $page_no - 1 ]; if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) { if ( has_block( 'more', $content ) ) { // Remove the core/more block delimiters. Вони будуть йти до кінця $content is split up. $content = preg_replace( '/<!-- /?wp:more(.*?) -->/', '', $content ); } $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-->' ) && ( ! $elements['multipage'] || 1 == $elements['page'] ) ) { $strip_teaser = true; } $teaser = $content[0]; if ( $elements['more'] && $strip_teaser && $has_teaser ) { $teaser = ''; } $output .= $teaser; if ( count( $content ) > 1 ) { if ( $elements['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( $_post ) . "#more-{$_post->ID}" class="more-link">$more_link_text< /a>", $more_link_text); } $ output = force_balance_tags ($ output); } } return $output; }
Зв’язані функції
loop (Цикл WP)
Записи: пости, сторінки, …
- edit_post_link()
- get_delete_post_link()
- get_edit_post_link()
- get_permalink()
- get_post_field()
- get_post_status()
- get_post_time()
- get_sample_permalink()
- get_the_date()
- get_the_modified_date()
- get_the_modified_time()
- get_the_permalink()
- get_the_time()
- get_the_title()
- get_the_title_rss()
- has_excerpt()
- post_password_required()
- register_post_status()
- single_post_title()
- the_excerpt_rss()
- the_modified_date()
- the_title()
- the_title_attribute()
Сторінки: 1 2