How do I place the After Post Widget on the homepage?

Community Forums Forums Design Tips and Tricks How do I place the After Post Widget on the homepage?

This topic is: resolved

This topic contains 11 replies, has 2 voices, and was last updated by  WoodlandCoyote 1 year, 6 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #39980

    WoodlandCoyote
    Participant
    Post count: 171

    The After Post Widget only displays on the single (permalink) post page. I’d like it to display at the bottom of my posts on the homepage and in my archives, too.

    I’m familiar with conditional tags, but I’m not sure how to make this happen. How do I write a function that will allow for multiple placements of this widget?

    Thank you!

    EDITED TO ADD — I’d prefer to address this via a function instead of using the Simple Hooks Plugin. :)

    #40048

    braddalton
    Participant
    Post count: 10562

    Link to your site please.

    And paste the code here (using shortcodes which you find in FAQ No.5) so i can edit it.


    #40113

    WoodlandCoyote
    Participant
    Post count: 171

    Hi Brad,

    Thanks so much for helping me out with this. Which code would you like me to paste here?

    :)

    #40119

    braddalton
    Participant
    Post count: 10562

    Just the function or the link to the page you got the code.


    #40126

    WoodlandCoyote
    Participant
    Post count: 171

    Oh, thanks for clarifying!

    Actually, the After Post widget is really just a widgetized area that’s built in to my theme. It might be a part of Genesis, I’m not sure.

    If you go to the widgets page, you’ll see on the far right the Primary Sidebar, Header Right, etc. It’s listed there. Instead of using the Simple Hooks plugin, which I intend to delete, I’d like to use this widgetized After Post area.

    But for some reason they’ve designed it so that any widgets in that area only display on the single page. I’ve typed in some text as a placeholder so that you can see this. My website is under construction, but I’ll remove that while we work on figuring this out. Here’s a link to my homepage: Hello!!

    Please ignore the slow loading photo in the sidebar. It’s just another placeholder, as are the four or five breaks just above the After Post box. I think some conditional tags are needed, which is easy enough, but I’m not sure how to write the function.

    Thank you. You’re a big help in these forums.

    #40141

    braddalton
    Participant
    Post count: 10562

    You can use this code with any genesis_hook outside the loop:

    Example:

    • genesis_after_loop
    • genesis_after_content
    • genesis_before_sidebar_widget_area
    • genesis_after_sidebar_widget_area
    • genesis_after_content_sidebar_wrap
    • get_footer
    • genesis_before_footer
    • genesis_footer

    Code not displaying? Grab it on Github.

    Copy the code from the view raw link and paste it at the end of your child themes functions.php file using a code editor like Notepad++.

    Change the conditional tag to suit your needs.


    #40183

    WoodlandCoyote
    Participant
    Post count: 171

    Brad, this worked perfectly.

    For anyone reading this, instead of adding a condition to the existing After Post widget area, he gave me instructions on how to create a custom widget. It shows up on the Appearance > Widgets page.

    I swapped the hook with genesis_after_post_content and then added is_single, and now it display exactly where I want it.

    This is brilliant. Thank you for taking the time to help me!!

    #40369

    WoodlandCoyote
    Participant
    Post count: 171

    Brad, I have a question . . .

    I’d like the custom widget content to display below all of my full-length posts. Using conditional tags for home and single, this worked just great. The widget content doesn’t show up on my archive or search result pages. But it does show up when you click pagination links at the bottom of my homepage.

    The front page displays full-length posts, and I decided to display excerpts on the remaining pages that are accessible via pagination. But those are showing my share links function and the widget.

    Here’s a link to a sample archive page, which look nice:

    Archives for the month of April

    And here’s a link to Page 2 accessed via the homepage pagination links:

    Excerpts with widget content

    How do I target post excerpts via conditional tags? Or is there a way to target anything with /page/ in the link?

    Thank you!!

    #40382

    WoodlandCoyote
    Participant
    Post count: 171

    I’m wondering if is_page can be used and the entire array of numbered pages somehow targeted?

    If I add a conditional tag to the custom widget and my share function, this will place the code there, since “true” is the default, I think. So how do I use a condition that blocks the content from displaying if that condition is met?

    #40385

    WoodlandCoyote
    Participant
    Post count: 171

    Ugh.

    If I’m understanding this correctly, array references numbered pages. This codex article says specifying an empty array results in a condition of “true.” So if I use is_page(array()) this means I’m telling the wizard hootchie to insert that content on all numbered pages, instead of removing it, which it’s already doing.

    Someone let me know if I should start a new thread to learn how to use conditions. Learning how to use conditions is giving me a condition, I’ll say that much. :)

    #40386

    WoodlandCoyote
    Participant
    Post count: 171

    Better yet, can I just target the homepage and single post pages?

    The conditions is_home and is_front_page place my share function and custom widget below my excerpts on the numbered pages, so they don’t target just the homepage.

    #40406

    WoodlandCoyote
    Participant
    Post count: 171

    Here’s the code to insert after your other conditional tags:

    `if ( get_query_var( ‘paged’ ) >= 2 )
    return;`

    Someone was kind enough to help with this. I played around with ‘paged’, but not like this. Not even close. She was a huge help.

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

The topic ‘How do I place the After Post Widget on the homepage?’ is closed to new replies.