astra_the_post_title( string $before = '', string $after = '', int $post_id, bool $echo = true )

Wrapper function for get_the_title() for blog post.


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_post_title( $before = '', $after = '', $post_id = 0, $echo = true ) {

		$enabled = apply_filters( 'astra_the_post_title_enabled', true );
		if ( $enabled ) {

			$title  = astra_get_the_title( $post_id );
			$before = apply_filters( 'astra_the_post_title_before', $before );
			$after  = apply_filters( 'astra_the_post_title_after', $after );

			// This will work same as `the_title` function but with Custom Title if exits.
			if ( $echo ) {
				echo $before . $title . $after; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
			} else {
				return $before . $title . $after;
			}
		}
	}

Changelog

Changelog
Version Description
1.0.15 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.