Community Forums › Forums › Archived Forums › General Discussion › Add a div around my entry-title and breadcrumb trail
Tagged: add a div, breadcrumb, entry-title
- This topic has 4 replies, 2 voices, and was last updated 8 years, 11 months ago by
leighm.
-
AuthorPosts
-
April 4, 2016 at 9:19 am #182887
leighm
MemberHi,
I've moved my entry-title and breadcrumb trail above the content and sidebar using this code:
//Moves titles above content and sidebar remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); add_action( 'genesis_after_header', 'genesis_do_post_title', 20 ); //this removes post titles from blog archive pages as well //Add titles back to home page, single posts, categeory archives and one specific page add_action('get_header', 'move_other_post_titles'); function move_other_post_titles() { if (is_home() || is_single() || is_page('contact-me') || is_category()) { // added conditional 'or is_single' and 'or is_category' remove_action( 'genesis_after_header', 'genesis_do_post_title', 20 ); add_action( 'genesis_entry_header', 'genesis_do_post_title' ); } } //* Reposition the breadcrumbs remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' ); add_action( 'genesis_after_header', 'genesis_do_breadcrumbs', 19);
The two divs now appear between the nav tag and the site-inner div, and do not have any div's wrapped directly around them. I want to give them 2 div's: 1 to apply the wrap class so they stay within the max width of the site, and outside that I want another div, so I can add a background image that will extend the full width of the view port. Something like this:
<div class="title-background"> <div class="wrap"> <div class="breadcrumb" itemprop="breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList">You are here: <span class="breadcrumb-link-wrap" itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem"><a href="http://localhost/smcu/"> <span itemprop="name">Home</span></a></span> <span aria-label="breadcrumb separator">/</span> <span class="breadcrumb-link-wrap" itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem"> <a href="http://localhost/smcu/sample/"><span itemprop="name">Sample Page</span></a></span> <span aria-label="breadcrumb separator">/ </span> Sub Page 1.1</div> <h1 class="entry-title" itemprop="headline">Sub Page 1.1</h1></div></div>
The div's with the class names title-background, and wrap are the ones I'd like to add and close them after the h1 tag.
Is there some way I can do this in genesis?
Thanks.
April 5, 2016 at 2:32 pm #183012carasmo
ParticipantNot exactly sure what you are doing, why remove and add back? Use conditionals for just those post types in the array in the variable.
/** * * Move Post Titles and Breadcrumbs on $post_types * Add presentational .wrap * */ function prefix_move_post_titles() { $post_types = array( 'post', 'page' ); // add CPTs here too with the same syntax if ( is_singular( $post_types ) ) { remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' ); echo '<div class="wrap">'; genesis_do_post_title(); genesis_do_breadcrumbs(); echo '</div>'; } } add_action( 'genesis_after_header', 'prefix_move_post_titles' );
April 6, 2016 at 1:55 am #183024leighm
MemberThat's perfect, Carasmo. That's exactly what I wanted to do. I wasn't aware that I could echo markup in the function like that. This is my first proper site using Genesis, so still very much on a learning curve. Thanks so much for your help.
On another note: I notice on the sites that you develop, you add a + sign to menu items that have sub items, which is great. Is that a function or how is that done? I hope you don't mind me using your work for inspiration : )
Maybe I should open up a new ticket to ask this specific question?
April 6, 2016 at 4:33 am #183032carasmo
ParticipantThanks! Re: the submenus, that is not a function, it's mostly CSS and jQuery. Due to a lack of time, I don't have a tutorial on how it's done, probably next month or two.
April 6, 2016 at 4:50 am #183034leighm
MemberNo problem. Thanks Carasmo. I'll look into myself in the meantime.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.