Post title is being displayed instead of Page title
-
I’ve created a simple function to display the page title. I’ve had to use some conditionals to try and change the title on the blog to use wp_title(); because get_the_title ends up displaying a post title instead of the page title. I’ve used this code but it doesn’t seem to work, I’m still getting a post title.
function ls_page_title() { $checkbox = get_post_meta( get_the_id(), 'ls_disable_page_title', true); // $pageTitle = get_post_meta( get_the_id(), 'ls_page_title', true) ? get_post_meta( get_the_id(), 'ls_page_title', true) : get_the_title(); if ( is_page( get_option('page_for_posts') ) ) { $pageTitle = wp_title('', false); } else { $pageTitle = get_post_meta( get_the_id(), 'ls_page_title', true) ? get_post_meta( get_the_id(), 'ls_page_title', true) : get_the_title(); } if ( $checkbox !== '1' ) { echo '<h1 class="page-title">' . $pageTitle . '</h1>'; } }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Post title is being displayed instead of Page title’ is closed to new replies.