Community Forums › Forums › Archived Forums › General Discussion › Place main title in a title bar, not children
Tagged: children, page-title, parent, post title
- This topic has 4 replies, 2 voices, and was last updated 9 years, 3 months ago by D. van de Kamp.
-
AuthorPosts
-
June 4, 2015 at 4:13 am #154825D. van de KampParticipant
Dear people,
How do I go about getting the title of the parent page in a title bar? For example, I have a news page. Above that page is a full width black banner with the title 'news'. What I want is the parent page's title 'news' to be in the title bar also when I go to a
a post. But I also still want to see the title of the post above the post.remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); -> removes the titles all together. But also removes all the post titles.
add_action( 'genesis_after_header', 'gs_create_entry_title_banner' );
function gs_create_entry_title_banner()
{
$parent_title = get_the_title($post->post_parent);
echo '<div class="title-bar">';
echo '<div class="wrap title-bar-inner">';
echo $parent_title;
echo '</div></div>';
}works in the sense that it now places the title in a separate area right after the header, but for some reason it now seems to grab the first post title and uses that as the page title. It doesn't grab the parent. And I still have the problem that the post titles were removed alltogether.
Last but not least, I don't want this title bar on the home page.
Can anyone help me?
http://localhostJune 4, 2015 at 4:25 am #154827SavvyJackieMemberJust a shot in the dark, but would this help?
http://wpdev.co/code/parent-page-title/
Web Designer and Developer at Savvy Jackie Designs | Lucky with plants | @SavvyJackie
Got your question answered here? Please pay it forward by helping someone else. I’m sure there is at least one question you can answer. 🙂
June 4, 2015 at 9:44 am #154862D. van de KampParticipantThanks, but for some reason it keeps using the last added post as the page title for the archive page and it keeps adding the post title in the title bar. So that didn't work for me unfortunately
June 11, 2015 at 4:02 am #155824D. van de KampParticipantAnyone else able to help? So what I want is for the custom post types "news, projects and student assignments" that the page title just below the header always shows "news, projects or student assignments" even when I go to a deeper level.
But for the deeper level I also still want the post title just above the content.So e.g. Header with navigation, then bar with title 'News' then content area with title of the news item, then content of news item.
June 12, 2015 at 2:56 am #155957D. van de KampParticipantSo for anyone looking for a sollution. I finally found a work around to accomplish what I wanted. Here's the code:
/**
* Move the title just after the header:
*/
add_action( 'genesis_after_header', 'dvdk_create_entry_title_banner' );
function dvdk_create_entry_title_banner() {if ( is_post_type_archive( 'news' ) || is_singular( 'news' ) )
$parent_title='News';
elseif ( is_post_type_archive( 'projects' ) || is_singular( 'projects' ) )
$parent_title='Projects';
elseif ( is_post_type_archive( 'student-assignments' ) || is_singular( 'student-assignments' ))
$parent_title='Student assignments';
else
$parent_title = get_the_title( $post->post_parent );
echo '<div class="title-bar">';
echo '<div class="wrap title-bar-inner">';
echo $parent_title ;
echo '</div></div>';
} -
AuthorPosts
- The topic ‘Place main title in a title bar, not children’ is closed to new replies.