Community Forums › Forums › Archived Forums › Design Tips and Tricks › Feature Post above the Blog listing
Tagged: blog listing, Feature Blog Entry
- This topic has 13 replies, 2 voices, and was last updated 10 years, 10 months ago by Brad Dalton.
-
AuthorPosts
-
June 11, 2013 at 9:15 am #45258csbeckMember
I am recreating a blog section from a pre-existing blog. The original blog has a single featured blog post above the listing of the rest of the blog postings on the blog list page.
Existing Site: http://www.virtualworks.com/blog/
New Site: http://acquireb2bdev.com/blog
You'll see that on the existing site there's a blog posting "How is VirtualWorks establishing a new category?" - this is a featured post and is displayed at the top of the page. It's still there when I view older posts. It's above the listing of the rest of the posts (post loop).
So is there a way that perhaps I could create a new Category and call it Featured and then have the Blog listing page show the Featured post(s) above the rest of the list?
I tried searching for this topic but didn't find relevant topics.
Thanks so much! Chris
June 11, 2013 at 9:17 am #45259csbeckMemberBTW - the existing site used a plugin called "Yet Another Featured Posts Plugin" but I'm wondering if it can be done by just hooking a little bit of code.
June 11, 2013 at 9:25 am #45263Brad DaltonParticipantNew widget area would be the best because you can drag in the Genesis featured post widget:
Code not displaying? grab it on Github.
You could also use the page template conditional:
if (is_page_template('blog.php') ) {
Even added a curly bracket for you because i know how much you love them Chris!!
June 11, 2013 at 9:42 am #45266csbeckMemberHey, Brad to the rescue again! And look, you put in the curly brackets! You're so kind.
This works like a charm - as expected - except it's not in the right place exactly. Can you help again by helping figure out what hook to put it in? I thought it should have been the before the loop as you did it, but the title of the page is coming within the loop. Strange. I must be making a mess of things.
Thanks so much for your continued support!
June 11, 2013 at 9:54 am #45274Brad DaltonParticipantWhat theme are you using?
If you're running HTML 5, the loop hooks have changed. http://www.briangardner.com/code/genesis-html5-loop-hooks/
June 11, 2013 at 9:54 am #45275csbeckMemberAgency. Sorry for not including that.
June 11, 2013 at 9:59 am #45281Brad DaltonParticipantTry changing
genesis_before_loop
to
genesis_before_entry
if its a HTML 5 enabled child theme. Otherwise you may need to change the conditional tag.
June 11, 2013 at 10:02 am #45283csbeckMemberThanks. It disappeared.
So that didn't work. Bummer.
June 11, 2013 at 10:21 am #45293Brad DaltonParticipantThis is what i used and it worked:
add_action( 'genesis_before_loop', 'wpsites_before_blog_widget', 5 ); function wpsites_before_blog_widget() { if ( is_page('11465') ) { echo '<div class="before-blog">'; dynamic_sidebar( 'before-blog' ); echo '</div><!-- end .before-blog -->'; } }
I used the page-id from the source code and running XHTML
June 11, 2013 at 10:28 am #45295csbeckMemberThanks. I used your exact code and put in my id (69) and it shows up but above the title area still.
Perhaps this issue is being generated by me using the Genesis Simple Hooks. I needed to create a section for the title and subtitle (together) that needed to not affect the content location below. So I added a special div for the Title and Subtitles. So in the hooks I did the following:
`genesis_before_post_title`:
<div class="page-title-container">
`genesis_before_post_content`:
</div> <!-- end page-title-container -->So perhaps this might be messing with our attempt to add the widget below the title.
If I were to add some PHP code (your function from above) in that hook with the end div, what would the code be?
Also, just for my knowledge, what is the number "5" for in your code above? The earlier code had a "9".
June 11, 2013 at 10:42 am #45297csbeckMemberGetting close. I changed the action to say:
`add_action( 'genesis_after_post_title', 'wpsites_before_blog_widget', 5 );`
Now I just have to push the loop content down. I thought I'd use "display: block;" but that's not doing it. Any thoughts?
June 11, 2013 at 10:47 am #45299Brad DaltonParticipant5 is the third parameter for positioning. The default is 10 so you can add 5 if you want to hook content in before a function using the same hook as long as its a number below what the function uses.
But it can also depend on where the function is in the file also. If there's 2 functions using the same hook and both aren't using the third parameter, the one highest in the file gets priority positioning.
I tried simple hooks with your code and it makes no difference. The widget outputs the content before the posts which is what you want isn't it?
Must be something else.
I would never change any of the defaults like that because then you can start to cause big problems.
June 11, 2013 at 11:12 am #45304csbeckMemberYes it is what I want. What defaults are you referring to that I shouldn't change?
I think I've got it working correctly now. There was a style that was making the area a set height.
Thanks so much for you sticking with me through this!
June 11, 2013 at 11:33 am #45308Brad DaltonParticipantGoof stuff.
Referring to the page-title-container.
When i changed the hook it didn't display for me.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.