Support » Theme: Hexa » Thumbnails 4 single posts

  • Is there a way to add post thumbnails to standard posts and audio posts, just like in the image post?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Kathryn

    (@zoonini)

    Automattic Happiness Engineer

    Yes, you can do that with a child theme.

    Making a child theme means your changes won’t be overwritten when you update the theme. If you’re new to child themes, you can explore these guides:

    http://codex.wordpress.org/Child_Themes
    http://op111.net/53/
    http://vimeo.com/39023468

    If you need help with the code, please let me know whether you’re looking to add featured images for standard and audio posts on the blog index page, or on single posts, or both?

    Thank you so much, Kathryn!

    I am using Circa, a child theme of hexa. Obviously there is no way to create a child of a child, is that right? Therefore I have modified Circa itself. Have added an extra stylesheet and have changed the existing page templates. Is there a better way to modify a child?

    I want to add featured images on single posts. They already are there in the blog loop and are in use for image posts, but audio and standard single posts don´t show featured images.

    For now I have used the plugin “get the image” and it´s working fine. But I am pretty sure there is a lighter way to solve this issue. Thank you for your help!

    Moderator Kathryn

    (@zoonini)

    Automattic Happiness Engineer

    Obviously there is no way to create a child of a child, is that right?

    You can actually make a grandchild theme:

    Creating Grandchild Themes

    Therefore I have modified Circa itself.

    If you don’t go the grandchild route, I suggest you fork the theme at that point and call it something else, otherwise you will lose every change you made if you update the theme.

    I’ll post separately about the changes needed to add featured images on single posts.

    Moderator Kathryn

    (@zoonini)

    Automattic Happiness Engineer

    What you’ll need to do is find the file content-single.php in Hexa and place a copy of it in Circa, or if your grandchild theme folder, according to the tutorial above.

    Line 10 is what controls where the featured image is displayed on single posts:

    <?php if ( '' != get_the_post_thumbnail() && 'image' == $format ) : ?>

    That code says “if the post has a featured image and is an image format post.” You’ll want to modify it to include standard and audio post formats, by changing that line to this:

    <?php if ( has_post_thumbnail() && ( has_post_format( array( 'image', 'audio' ) ) || ! has_post_format() ) ) : ?>

    Be aware that if you include this file in Circa directly and subsequently update Circa when we release a new version, you will lose your changes. You’ll need to restore your modified files from a backup, so be sure to always keep your changed copies of the files handy and remember to restore them after each update.

    Let me know how it goes!

    Grandchild theme as a plugin: Works just fine, what an unusual and creative idea! A friend recommended adding the definition of the child in the grandchild-functions.php. What do you think about it?

    if ( 'Child' == wp_get_theme()->get( 'Template' ) ) {
    # your changes
    }

    Thumbnails: Wonderful! Your explanation is exactely what I was looking for.

    Thank you so much, Kathryn!

    Moderator Kathryn

    (@zoonini)

    Automattic Happiness Engineer

    Glad the grandchild tutorial worked out for you and you’re very welcome!

    A friend recommended adding the definition of the child in the grandchild-functions.php. What do you think about it?

    Two of our developers looked at the code your friend suggested and they both agreed it was unnecessary. If your grandchild theme is working fine you can leave it as is.

    Do keep an eye on your site following any Hexa/Circa updates to make sure everything is still working normally, as the grandchild route isn’t officially supported and is definitely unusual, as you say. 😉

    Good luck with your site!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Thumbnails 4 single posts’ is closed to new replies.