Created
January 17, 2019 14:36
-
-
Save jonbrockett/5cc8cbc20f8fa2c3f7bde1ea1f5e3197 to your computer and use it in GitHub Desktop.
Get Posts (Blog) Page Title (Custom WP Function)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** The Posts (Blog) Page Title */ | |
| require_once( 'library/get-posts-page-title.php' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Get and Display the Posts (Blog) Page Title | |
| * 04/26/2018 | |
| * @author Jonathan Brockett | |
| * | |
| * Requires: WordPress @link https://codex.wordpress.org/ | |
| */ | |
| /** | |
| * Gets the posts (blog) page title | |
| * @return string The page title of the posts pages, usually the blog page | |
| */ | |
| function get_the_posts_page_title() { | |
| $page_for_posts = get_option( 'page_for_posts' ); // Gets the page the posts (blog) uses | |
| $posts_page_title = get_the_title($page_for_posts); | |
| return $posts_page_title; | |
| } | |
| /** | |
| * Displays the posts (blog) page title | |
| */ | |
| function the_posts_page_title() { | |
| echo get_the_posts_page_title(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * The Posts Page Title (The Blog Page) | |
| */ | |
| ?> | |
| <?php if( is_home() && !is_front_page()): ?> | |
| <header> | |
| <h1 class="entry-title"><?php the_posts_page_title(); ?></h1> | |
| </header> | |
| <?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment