• 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

PHP Error

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 › PHP Error

This topic is: resolved

Tagged: https://myersfitness.co.uk/page-post-test/

  • This topic has 6 replies, 2 voices, and was last updated 4 years, 9 months ago by PunkUK.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • August 29, 2018 at 1:36 pm #222796
    PunkUK
    Member

    Hi, can anyone please explain why I am getting this error:
    pro/functions.php on line 341

    Notice: Trying to get property of non-object in /home/chocol37/public_html/myersfitness.co.uk/wp-content/themes/infinity-pro/functions.php on line 341

    Here is the php:
    /** Add the featured image section */
    add_action( 'genesis_after_header', 'full_featured_image' );
    function full_featured_image() {
    if ( is_front_page() ) {
    echo '<div id="full-image"></div>';
    }
    elseif ( is_singular( array( 'post', 'page' ) ) && has_post_thumbnail() ){
    echo '<div id="full-image">';
    echo get_the_post_thumbnail($thumbnail->ID, 'header');
    echo '</div>';
    }
    }

    When I use this in Altitude Pro it is fine.

    Many thanks to anyone who can help.

    http://php, hero image, altitude pro
    August 29, 2018 at 6:15 pm #222802
    Victor Font
    Moderator

    Since you didn't post line numbers, which line is causing the hiccup?


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    August 29, 2018 at 11:26 pm #222805
    PunkUK
    Member

    Hi Victor,

    Thank you so much for replying. The line is: echo get_the_post_thumbnail($thumbnail->ID, 'header');

    Many thanks.

    August 30, 2018 at 7:17 am #222809
    Victor Font
    Moderator

    Where are you initializing $thumbnail->ID?

    You're passing an object element as a parameter, but you're not initializing the object anywhere. The error is correct.

    This is how to use that function: https://developer.wordpress.org/reference/functions/get_the_post_thumbnail/


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    August 30, 2018 at 12:32 pm #222816
    PunkUK
    Member

    Hi Victor,

    Thank you again for your reply. I wish I could answer your question but I don't know the answer. I used this code on the Altitude Pro theme and it works fine but for some reason I get this error with Infinity Pro.

    If you have any suggestions I would most grateful. Would help to see the full functions PHP?

    August 30, 2018 at 12:59 pm #222819
    Victor Font
    Moderator

    If that seems to work in Altitude Pro, then you are either not hitting the condition to trigger the notices, PHP notices are turned off, or you missed copying the code where that parameter is initialized. There's no way that code should work anywhere without initializing the parameter.

    The theme has nothing to do with whether that code works or not.

    You are passing an uninitialized object as a parameter to the WordPress get_the_post_thumbnail() function. The first parameter is either the post id or null. The default is null.

    I would go back to wherever you got the code from and see what you're missing. I can't help you further without access to the back-end of the site.

    If you can't figure this out, you may have to hire a developer to help you.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    August 31, 2018 at 1:23 am #222839
    PunkUK
    Member

    No Problem. I have fixed it.

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘PHP Error’ is closed to new 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