astra_the_title( string $before = '', string $after = '', int $post_id, bool $echo = true )
Wrapper function for the_title()
Description
Displays title only if the page title bar is disabled.
Parameters
- $before
-
(string) (Optional) Content to prepend to the title.
Default value: ''
- $after
-
(string) (Optional) Content to append to the title.
Default value: ''
- $post_id
-
(int) (Optional) default to 0. Post id.
- $echo
-
(bool) (Optional) default to true.Whether to display or return.
Default value: true
Return
(string|void) String if $echo parameter is false.
Source
File: inc/core/common-functions.php
function astra_the_title( $before = '', $after = '', $post_id = 0, $echo = true ) {
$title = '';
$blog_post_title = astra_get_option( 'blog-post-structure' );
$single_post_title = astra_get_option( 'blog-single-post-structure' );
if ( ( ! is_singular() && in_array( 'title-meta', $blog_post_title ) ) || ( is_single() && in_array( 'single-title-meta', $single_post_title ) ) || is_page() ) {
if ( apply_filters( 'astra_the_title_enabled', true ) ) {
$title = astra_get_the_title( $post_id );
$before = apply_filters( 'astra_the_title_before', $before );
$after = apply_filters( 'astra_the_title_after', $after );
$title = $before . $title . $after;
}
}
// This will work same as `the_title` function but with Custom Title if exits.
if ( $echo ) {
echo $title; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
return $title;
}
}
Expand full source code Collapse full source code View on Trac