Community Forums › Forums › Archived Forums › Design Tips and Tricks › Adding a wrap div inside entry-content div
Tagged: functions.php, structural wraps
- This topic has 8 replies, 3 voices, and was last updated 9 years, 2 months ago by Brad West.
-
AuthorPosts
-
January 23, 2015 at 1:12 am #138375Brad WestMember
I'd like to add a
<div class="wrap">
inside<div class="entry-content">
.It made sense to me the following would work, but it didn't.
`
add_action( 'genesis_before', 'entry_content_wrap_open' );
function entry_content_wrap_open() {
echo '<div class="wrap">';
}add_action( 'genesis_before', 'entry_content_wrap_close' );
function entry_content_wrap_close() {
echo '</div>';
}
`
Any ideas how to get the following?
`
<div class="entry-content">
<div class="wrap">
...
</div>
</div>
`
January 23, 2015 at 1:55 am #138378Genesis DeveloperMemberJanuary 23, 2015 at 2:01 am #138379Brad WestMemberI tried that, but it's not adding them where I want them. I need the wrap inside the entry-content div.
January 23, 2015 at 2:08 am #138380Genesis DeveloperMemberOk. Then use genesis_before_content and genesis_after_content hook
January 23, 2015 at 2:18 am #138385Brad WestMemberThat adds it after the content-sidebar-wrap like this:
`
<div class="content-sidebar-wrap">
<div class="wrap">
<main class="content">
<article class="entry">
<header class="entry-header"></header>
<div class="entry-content">
...
</div>
<footer class="entry-footer"></footer>
</article>
</main>
</div>
</div>
`
What I'm looking for is this:
`
<div class="content-sidebar-wrap">
<main class="content">
<article class="entry">
<header class="entry-header"></header>
<div class="entry-content">
<div class="wrap">
...
</div>
</div>
<footer class="entry-footer"></footer>
</article>
</main>
</div>
`
January 23, 2015 at 2:30 am #138386ᴅᴀᴠɪᴅMemberThe answer is this
//* Add Wraps to Entry Content add_action( 'genesis_entry_content', 'entry_content_wrap_open', 1 ); function entry_content_wrap_open() { echo '<div class="wrap">'; } add_action( 'genesis_entry_content', 'entry_content_wrap_close', 25 ); function entry_content_wrap_close() { echo '</div>'; }
I love helping creative entrepreneurs build epic things with WP & Genesis.
January 23, 2015 at 2:35 am #138387Brad WestMemberThat worked. Thanks so much David.
If I could push my luck, is there any documentation on when and how to use the priority settings? I understand how this works now that I see it, but I wouldn't have thought of it myself.
January 23, 2015 at 2:43 am #138389ᴅᴀᴠɪᴅMemberApart from looking through the Genesis files to see where things currently are located and on what priority, I just remember where most are just as I've done it so many times.
Basic rule is obviously that the lower the number the higher priority. Priority is just the order in which they come first.
But it's all temporary in a way. The priority '25' in the code solves your problem, but if you started to add a lot of things into that same hook you would need to move that number to allow room.
Usually I stay away from priority '1' as you never know when you're going to add something extra on so its always nice to have the room. But in the case of adding a wrap then really you always want that as the first things so everything can be contained inside it.
The other basic rule is that if there is no number, then it is the same as having a priority of 10.
I love helping creative entrepreneurs build epic things with WP & Genesis.
January 23, 2015 at 2:46 am #138392Brad WestMemberCheers David. I appreciate the help.
-
AuthorPosts
- The topic ‘Adding a wrap div inside entry-content div’ is closed to new replies.