Feature Post above the Blog listing

Community Forums Forums Design Tips and Tricks Feature Post above the Blog listing

This topic is: resolved

This topic contains 13 replies, has 2 voices, and was last updated by  braddalton 1 year, 4 months ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #45258

    csbeck
    Participant
    Post count: 135

    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

     

     

    #45259

    csbeck
    Participant
    Post count: 135

    BTW – 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.

    #45263

    braddalton
    Participant
    Post count: 10263

    New 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:
    [php]
    if (is_page_template(‘blog.php’) ) {
    [/php]

    Even added a curly bracket for you because i know how much you love them Chris!!


    #45266

    csbeck
    Participant
    Post count: 135

    Hey, 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!

    #45274

    braddalton
    Participant
    Post count: 10263

    What theme are you using?

    If you’re running HTML 5, the loop hooks have changed. http://www.briangardner.com/code/genesis-html5-loop-hooks/


    #45275

    csbeck
    Participant
    Post count: 135

    Agency. Sorry for not including that.

    #45281

    braddalton
    Participant
    Post count: 10263

    Try changing
    [php]
    genesis_before_loop
    [/php]
    to
    [php]
    genesis_before_entry
    [/php]
    if its a HTML 5 enabled child theme. Otherwise you may need to change the conditional tag.


    #45283

    csbeck
    Participant
    Post count: 135

    Thanks. It disappeared.

    So that didn’t work. Bummer.

    • This reply was modified 1 year, 4 months ago by  csbeck.
    • This reply was modified 1 year, 4 months ago by  csbeck.
    #45293

    braddalton
    Participant
    Post count: 10263

    This is what i used and it worked:
    [php]
    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 –>’;

    }

    }
    [/php]

    I used the page-id from the source code and running XHTML


    #45295

    csbeck
    Participant
    Post count: 135

    Thanks. 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″.

    #45297

    csbeck
    Participant
    Post count: 135

    Getting 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?

     

    #45299

    braddalton
    Participant
    Post count: 10263

    5 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.


    #45304

    csbeck
    Participant
    Post count: 135

    Yes 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!

    #45308

    braddalton
    Participant
    Post count: 10263

    Goof stuff.

    Referring to the page-title-container.

    When i changed the hook it didn’t display for me.


Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.