Unexpected "Undefined property: WP_Post_Type::$post_type"

Notice: Undefined property: WP_Post_Type::$post_type in wp-content/themes/pro/framework/functions/custom-sidebars.php on line 95

Hi Jeff,

Thanks for writing in! Basically you can ignore PHP notices by disabling WordPress debug mode. Please refer to the following WordPress documentation handle on how to disable debugging mode (https://codex.wordpress.org/WP_DEBUG).

Further, if you’re using a PHP version below v5.5.x, you can try switching to adifferent PHP version like v5.6.x or later and see if you’re getting the same issue.

Also it’s important to see whether you have fully updated including WordPress core, X/Pro theme and it’s plugins. You can see the latest version from here (https://wordpress.org/download/) and update accordingly by following this guide (https://codex.wordpress.org/Upgrading_WordPress).

You can see latest version of X theme and it’s compatible version information from here (https://theme.co/apex/forum/t/troubleshooting-version-compatibility/195) and then you can follow our update guide here (https://theme.co/apex/forum/t/setup-updating-your-themes-and-plugins/62)

Hope that helps.
Thanks.

Thank you for your reply. No, that doesn’t help. Keeping your code clean would help.

Hello Jeff,

@Darshana explained what the PHP notice is all about and how you can get rid of this.
We always get the code of the theme as clean as possible. Normally notices will display once in a while especially if you have assigned a variable to a null value or that in your case, you may have created a sidebar and assigned to an unknown or removed post type. We would be happy to investigate more about on this notice in your site. Would you mind providing us the url of your site with login credentials so we can take a closer look?

To do this, you can create a secure note with the following info:
– Link to your site
– WordPress Admin username / password

To know how to create a secure note, please check this out: https://theme.co/apex/forum/t/how-to-get-support/288

Thank you.

Is, I think, a helpful answer. Not correct, but helpful. It’s your code. Do with it as you please. I’d like to think I helped improve your regression testing. You’re welcome.

Hi Jeff,

From that file, there is just empty line on 95

I kept looking for $post_type but there are none

I assume this issue is triggered within Wordpress’s custom post type object and just displayed like that. The code is clean and I can’t reproduce this notice anywhere from my installation. Been searching it in the forum too and this seems an isolated case for this specific file.

Perhaps you can provide your admin login credentials so we could test it directly? Though, if this is caused by a 3rd party plugin or customization then we can’r really offer any fix.

Thanks!

Get back to me when you learn to use vi

$ vi wp-content/themes/pro/framework/functions/custom-sidebars.php

Hi Jeff,

It’s not about using vi, I know how to use it but I’m not saying I’m an expert in it. It just clearly shows that mine has different line numbers than your end. Perhaps you have customized it? Sorry, that’s just my guess I’m not totally saying you did. As a proof that it has different line numbers then this is the screenshot from my vi

If it’s due to the color scheme then I’ll check that too, I’ll let you know if I found something. You can also provide information like any idea how we can clean that part, it would be a great help :slight_smile: , I’ll just continue troubleshooting on my end.

I also preferred using other code editor that will make my work and troubleshooting faster :slight_smile: , but again, there should be no problem with line numbers if they are exactly the same files.

Thanks!

Sorry, I fat-fingered delete. The version you’re looking at doesn’t match v2.5.5
Any such changes would be made to pro-child/ not pro/.
This topic should be closed. I cannot fix what I didn’t break.
FWIW, the errant line is 86 in your version. The problem still exists in that version.