• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Add Avatar to MOCHA Home Featured Post Only

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add Avatar to MOCHA Home Featured Post Only

This topic is: resolved

Tagged: avatar, featured post, home, Mocha

  • This topic has 8 replies, 2 voices, and was last updated 9 years, 9 months ago by Brad Dalton.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • June 2, 2013 at 8:57 am #43603
    Kelli
    Member

    I've used  @braddalton 's wonderful code to add my avatar before the post title on single posts. I'm using Mocha and I'd like the avatar to show on the home page posts also but only on the 1st featured post---not on the following 6 excerpts on the home page.

    There must be a specific conditional to code it this way, but I can't figure it out. Can you Brad or anyone else figure out what that conditional would be?

    I've tried  if (is_single() || is_home() ) {  but it puts the avatar on the featured post and the 6 excerpts, but I would like the avatar on the 1st post (featured post) on the home page only.

    Help?

    Site: http://sweetnessoflife.com

    Thank you!

    -Kelli

    http://sweetnessoflife.com
    June 2, 2013 at 11:22 am #43621
    Brad Dalton
    Participant

    Hi Kelli

    Will that specific post change when you publish more posts? Or do you want it to stay on one specific post?

    Try this:

    if (is_sticky( '007' )  ) {
    

    Or

    if (is_sticky( '007' ) && is_home() ) {
    

    Or

     if (is_single('007') || is_home() ) { 
    

    Returns true if "Stick this post to the front page" check box has been checked for the current post.

    Change the 007 to the i.d of the post which you can grab from the source code or by hovering over the edit or delete button for that post.


    Tutorials for StudioPress Themes.

    June 3, 2013 at 6:14 am #43792
    Kelli
    Member

    Hi Brad, the post changes... it is always the most recent post published. Do you think there's a way in Mocha to identify it for this purpose?

    June 3, 2013 at 6:35 am #43800
    Brad Dalton
    Participant

    You'll need a query for that. I don't think there's a conditional tag for the most recent post.

    Once you have the query, you can then put it into a custom function with the code you have already.

    I'll see if I can get you the query.


    Tutorials for StudioPress Themes.

    June 3, 2013 at 8:01 am #43814
    Brad Dalton
    Participant

    Could you please paste the code you used for your home page here thanks.

    I'd like to test it with the query and make sure it works before posting the entire snippet.


    Tutorials for StudioPress Themes.

    June 3, 2013 at 8:20 am #43819
    Kelli
    Member
    This reply has been marked as private.
    June 3, 2013 at 8:28 am #43822
    Brad Dalton
    Participant

    Here's the solution I tested which works:

    Code not displaying? Grab it from Github.

    Credit to s_ha_dum WordPress.stackexchange.com for the query.


    Tutorials for StudioPress Themes.

    June 3, 2013 at 8:54 am #43831
    Kelli
    Member

    That works perfectly! Thank you, Brad.

    Glad I found the idea on your site and happy to know you're helping here at StudioPress, too!

    June 3, 2013 at 11:34 am #43856
    Brad Dalton
    Participant

    No worries Kelli.

    Didn't get your private message. Not sure why.


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble